[Ironruby-core] Is the Fixnum size difference a problem?

Charles Oliver Nutter charles.nutter at sun.com
Fri Dec 21 17:07:41 EST 2007

John Messerly wrote:
> I think we can keep Fixnums at 32 bits, and fix div to throw. Just tried in JRuby:
> irb(main):001:0> 0x4000_0000_0000_0000.class
> => Fixnum
> irb(main):002:0> 0x4000_0000.div(0.0)
> FloatDomainError: Infinity
> They actually have 64bit Fixnums... wow :)

Yeah, we realized very recently that at some point we switches Fixnum to 
64 bits, and now we don't care to switch it back. So we're using a Java 
long primitive internally to represent it, and I believe we're stripping 
off the upper bit or two.

This issue actually came up today while I was fixing some spec failures 
in JRuby. The specs do check that Fixnum is four bytes...but I talked 
with Rubinius folks and they agree it should be made flexible enough for 
other size Fixnums, since even Ruby's own documentation says Fixnum may 
be different sizes on different hardware (and perhaps we may have used a 
64-bit machine to run Ruby at some point, leading to JRuby's 64-bit 

I don't think the precision of Fixnum is a specifiable detail, 
especially since there's no loss of precision from a rollover into 
Bignum...whenever that happens.

- Charlie

More information about the Ironruby-core mailing list