Awesome thank you Caleb and Axel. I had tried the fixnum but it wasn't working and then it occurred to me that it was being read in as a string. Thank you both for the quick answers. I appreciate the help. Caleb Clausen wrote: > On 1/3/10, Kvetch Kvetch <kvetch / gmail.com> wrote: >> Kvetch Kvetch wrote: >>> Hello, I am new to Ruby and was wondering if there is an easier/faster >>> way to determine if a bit is set in a number. For example, > [snip] >> >> Actually I suppose the bit check should read >> if ( x & y ) >= 1 >> Or I am still totally off. > > There's nonzero?, which ought to be a tad faster than >=1. So, write > this instead: > > if ( x & y ).nonzero? > > Or, if you incorporate Axel's suggestion to use Fixnum#[] as well, then: > > if x[3].nonzero? -- Posted via http://www.ruby-forum.com/.