Method: Integer#anybits?

Defined in:
numeric.c

#anybits?(mask) ⇒ Boolean

Returns true if any bit that is set (=1) in mask is also set in self; returns false otherwise.

Example values:

0b10000010  self
0b11111111  mask
0b10000010  self & mask
      true  self.anybits?(mask)

0b00000000  self
0b11111111  mask
0b00000000  self & mask
     false  self.anybits?(mask)

Related: Integer#allbits?, Integer#nobits?.

Returns:

  • (Boolean)


3710
3711
3712
3713
3714
3715
# File 'numeric.c', line 3710

static VALUE
int_anybits_p(VALUE num, VALUE mask)
{
    mask = rb_to_int(mask);
    return RBOOL(!int_zero_p(rb_int_and(num, mask)));
}