/* * call-seq: * ~big => integer * * Inverts the bits in big. As Bignums are conceptually 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" */ static VALUE rb_big_neg(x) VALUE x; { VALUE z = rb_big_clone(x); long i; BDIGIT *ds; if (!RBIGNUM(x)->sign) get2comp(z); ds = BDIGITS(z); i = RBIGNUM(x)->len; if (!i) return INT2FIX(~0); while (i--) ds[i] = ~ds[i]; RBIGNUM(z)->sign = !RBIGNUM(z)->sign; if (RBIGNUM(x)->sign) get2comp(z); return bignorm(z); }