views:

248

answers:

1

If I type this big integer:

puts 9997836544.class.to_s

and compile with ruby 1.86, it reports expectedly:

BigNum

while JRuby (1.1.4 in Netbeans) reports surprisingly:

Fixnum

I thought Java had a BigInteger class to correspond to the BigNum class in Ruby. If so, I would have expected JRuby and ruby to produce the same output.

+1  A: 

Found this JRuby bug report:

It seems that JRuby and MRI have different limits to separate Fixnum and Bignum.
...
So, MRI uses 0x3fffffff as the biggest FixNum under 32bit environment.
And JRuby always uses 64bit value: jruby -e 'p (0x7fffffffffffffff + 1).class' ---> Bignum.

So try a bigger number and you should get a BigNum as you expect.

Michael Myers
Unbelievable. Thanks for finding this.
It wasn't really that hard. http://www.google.com/search?q=jruby+bignum+fixnum
Michael Myers
But thanks for the rep. :)
Michael Myers