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 :
As expected, this comfortably fits into 32 bits, but so should this :
- Why has it gone to Bignum ? it shouldn’t do this until 0x80000000.
- 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.