Date: 2007-06-12 14:41
Sender: Darren Smith
I would expect it to equal 0|(1e20).to_i which is
100000000000000000000.
All of the bitwise functions have something like this:
if (TYPE(y) == T_BIGNUM) {
return rb_big_and(y, x);
}
val = FIX2LONG(x) & NUM2LONG(y);
A potential fix would be to convert y to integer type before
checking if it is a bignum, or to check the size of a float
and call rb_big_and in a special case. Another solution
would be to disallow all automatic conversion from float to
integer in bitwise operations.
The reason I think this is a problem is because the user is
not supposed to care if a number is a Fixnum or a Bignum, it
is supposed to be transparent. But in these cases there is
different behavior (an error) occuring depending on the size
of values, even though it is possible to proceed but as
Bignum instead. |