From: Ken Bloom Date: 2006-12-05T23:40:09+09:00 Subject: Re: Integer#to_s(2) works on x86, fails on x86_64 On Tue, 05 Dec 2006 23:24:57 +0900, Mihai Vlad wrote: > Kalman Noel wrote: >> Suraj Kurapati: >> >>> $ 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' >>> >> >> irb> "#{RUBY_VERSION} #{RUBY_PLATFORM} #{RUBY_RELEASE_DATE}" >> => "1.9.0 x86_64-linux 2006-10-16" >> irb> 2956350890592680056.to_s(2) >> => "10100100000111000100010111100010111001001011111011100001111000" >> >> 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:in `to_s' >> from (irb):2 >> >> Kalman >> >> > > Seems on 1.8.5 is ok aswell, so the problem is < 1.8.4 > > irb(main):001:0> "#{RUBY_VERSION} #{RUBY_PLATFORM} #{RUBY_RELEASE_DATE}" > => "1.8.5 x86_64-linux 2006-12-04" > irb(main):002:0> 2956350890592680056.to_s(2) > => "10100100000111000100010111100010111001001011111011100001111000" Yep. Here are the relevant changelog entries. Fri Aug 25 17:15:17 2006 Yukihiro Matsumoto * stable version 1.8.5 released. Sun Feb 5 21:05:34 2006 Hirokazu Yamamoto * 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 * numeric.c (fix_to_s): (2**32).to_s(2) fails with exception where sizeof(int) == 4 < sizeof(long). [ruby-core:7300] Sat Dec 24 18:58:14 2005 Yukihiro Matsumoto * stable version 1.8.4 released. -- Ken Bloom. PhD candidate. Linguistic Cognition Laboratory. Department of Computer Science. Illinois Institute of Technology. http://www.iit.edu/~kbloom1/