From: Paul Lutus Date: 2006-12-05T17:40:06+09:00 Subject: Re: Integer#to_s(2) works on x86, fails on x86_64 Suraj Kurapati wrote: > Hello, > > Can anyone explain why this is happening? > > > ---- on x86_64 ---- > > $ ruby -v > ruby 1.8.4 (2005-12-24) [x86_64-linux] > > $ irb >>> 2956350890592680056.to_s(2) > RangeError: integer 2956350890592680056 too big to convert to `int' > from (irb):1:in `to_s' > from (irb):1 > from :0 > > > ---- on x86 ---- > > $ ruby -v > ruby 1.8.4 (2005-12-24) [i486-linux] > > $ irb >>> 2956350890592680056.to_s(2) > => "10100100000111000100010111100010111001001011111011100001111000" > > > Thanks for your consideration. 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. -- Paul Lutus http://www.arachnoid.com