From: Stefan Mahlitz Date: 2006-12-05T18:45:25+09:00 Subject: Re: Integer#to_s(2) works on x86, fails on x86_64 Paul Lutus wrote: > It's way too large to fit into an old-style integer of 32 bits, but it fits > with two bits to spare in a 64-bit integer. Also, in Ruby, normally an > integer too large for the Fixnum class is automatically converted to a > Bignum, so this error should not have happened. > > Try this test: > > 32.upto(128) do |p| > puts 2 ** p > end > > See what happens on both platforms. BTW I am thinking this is an error in > the x86_64 Ruby code. The same Exception is thrown on my machine. From cpuinfo: processor : 0 vendor_id : AuthenticAMD cpu family : 15 model : 47 model name : AMD Athlon(tm) 64 Processor 3000+ stepping : 2 Operating System is Ubuntu 6.06 LTS. Ruby version (installed via OS package manager): ruby 1.8.4 (2005-12-24) [x86_64-linux]. 16.upto(128) do |p| n = 2 ** p puts("#{p}: #{n}: #{n.class}") end shows a conversion at 61: 2305843009213693952: Fixnum 62: 4611686018427387904: Bignum where to_s(2) fails at p == 31 16.upto(128) do |p| n = 2 ** p puts("#{p}: #{n}: #{n.class}") puts(n.to_s(2)) end 31: 2147483648: Fixnum RangeError: integer 2147483648 too big to convert to `int' Stefan