M
Mr Magpie
According to the Pickaxe book :
"A Fixnum holds Integer values that can be represented in a native
machine word (minus 1 bit). If any operation on a Fixnum exceeds this
range, the value is automatically converted to a Bignum."
In IRB :
=> 4
As expected, this comfortably fits into 32 bits, but so should this :
=> 4
1) Why has it gone to Bignum ? it shouldn't do this until 0x80000000.
2) Interestingly, BigNum has recognised it fits into 32 bits, but it was
upsized anyway !
I'm trying to do some performance critical bit manipulations (without
leaving ruby) and this means I'll be using BigNum unnecessarily.
Regards
Magpie
"A Fixnum holds Integer values that can be represented in a native
machine word (minus 1 bit). If any operation on a Fixnum exceeds this
range, the value is automatically converted to a Bignum."
In IRB :
=> 4
As expected, this comfortably fits into 32 bits, but so should this :
=> 4
1) Why has it gone to Bignum ? it shouldn't do this until 0x80000000.
2) Interestingly, BigNum has recognised it fits into 32 bits, but it was
upsized anyway !
I'm trying to do some performance critical bit manipulations (without
leaving ruby) and this means I'll be using BigNum unnecessarily.
Regards
Magpie