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.
irb> “#{RUBY_VERSION} #{RUBY_PLATFORM} #{RUBY_RELEASE_DATE}”
=> “1.8.4 x86_64-linux 2005-12-24”
irb> 2956350890592680056.to_s(2)
RangeError: integer 2956350890592680056 too big to convert to int' from (irb):2:into_s’
from (irb):2
On Tue, 05 Dec 2006 23:24:57 +0900, Mihai Vlad wrote:
RangeError: integer 2956350890592680056 too big to convert to int' RangeError: integer 2956350890592680056 too big to convert to int’
=> “1.8.5 x86_64-linux 2006-12-04”
irb(main):002:0> 2956350890592680056.to_s(2)
=> “10100100000111000100010111100010111001001011111011100001111000”
* numeric.c (fix_to_s): removed workaround for radix 2.
Historically,
rb_fix2str could only handle radix 8, 10, 16. (Rev1.37) But
for now,
it can handle radix 2…36. [ruby-Bugs#3438] [ruby-core:7300]
Sat Feb 4 15:56:37 2006 Hirokazu Yamamoto [email protected]
* numeric.c (fix_to_s): (2**32).to_s(2) fails with exception
where
sizeof(int) == 4 < sizeof(long). [ruby-core:7300]