title: Bitmasking alternatives in Ruby
body: <p>I'm trying to achieve a simple use case, where I need to restrict a comment only to those users who are mentioned in it. I'm trying to use bitmasking in ruby to control the access. I'm using the stored 'id' value of users in the database to calculate the binary values. </p>
  
  <p>[For eg, say example1@example.com's id is 140, I do a 2 ** 140 and store the hash. I allow access by doing a bitwise AND (&amp;) with the hash and if the value is not zero. Please check this link:  <a href="https://stackoverflow.com/questions/3867714/bit-banging-in-ruby">Bit banging in ruby</a> </p>
  
  <p>Now, the problem is when I have bigger id values (clearly if id column is a bigint, bitmasking is a big no-no). Is there any solution to this problem? If not bitmapping, how else can this use case be approached other than an intermediate normalized table? </p>