<<(p1)
public
Shifts big left numeric positions (right if numeric is
negative).
Show source
/*
* call-seq:
* big << numeric => integer
*
* Shifts big left _numeric_ positions (right if _numeric_ is negative).
*/
VALUE
rb_big_lshift(x, y)
VALUE x, y;
{
long shift;
int neg = 0;
for (;;) {
if (FIXNUM_P(y)) {
shift = FIX2LONG(y);
if (shift < 0) {
neg = 1;
shift = -shift;
}
break;
}
else if (TYPE(y) == T_BIGNUM) {
if (!RBIGNUM(y)->sign) {
VALUE t = check_shiftdown(y, x);
if (!NIL_P(t)) return t;
neg = 1;
}
shift = big2ulong(y, "long", Qtrue);
break;
}
y = rb_to_int(y);
}
if (neg) return big_rshift(x, shift);
return big_lshift(x, shift);
}