Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Why is 0x7FFFFFFF Bignum and not Fixnum ?
Mr Magpie
4/30/2007 4:04:00 AM
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 :
>> 0x3FFFFFFF.class
=> Fixnum
>> 0x3FFFFFFF.size
=> 4
As expected, this comfortably fits into 32 bits, but so should this :
>> 0x7FFFFFFF.class
=> Bignum
>> 0x7FFFFFFF.size
=> 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
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Why is 0x7FFFFFFF Bignum and not Fixnum ?
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password