Ruby Newbie homepage Ruby Newbie homepage

How to use

Quick guide

Official content
Returns true if all bits that are set (=1) in mask are also set in self; returns false otherwise.
Example values:
0b1010101  self
0b1010100  mask
0b1010100  self & mask
     true  self.allbits?(mask)

0b1010100  self
0b1010101  mask
0b1010100  self & mask
    false  self.allbits?(mask)
 
               static VALUE
int_allbits_p(VALUE num, VALUE mask)
{
    mask = rb_to_int(mask);
    return rb_int_equal(rb_int_and(num, mask), mask);
}
            

Was this page useful?