Method: Integer#~
- Defined in:
- numeric.c
#~ ⇒ Integer
One’s complement: returns a number where each bit is flipped.
Inverts the bits in an Integer. As integers are conceptually of infinite length, the result acts as if it had an infinite number of one bits to the left. In hex representations, this is displayed as two periods to the left of the digits.
sprintf("%X", ~0x1122334455) #=> "..FEEDDCCBBAA"
4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 |
# File 'numeric.c', line 4402
static VALUE
int_comp(VALUE num)
{
if (FIXNUM_P(num)) {
return fix_comp(num);
}
else if (RB_TYPE_P(num, T_BIGNUM)) {
return rb_big_comp(num);
}
return Qnil;
}
|