[前][次][番号順一覧][スレッド一覧][生データ]

yarv-dev-en:149

From: Brian Eng <beng jlab.org>
Date: Mon, 14 Aug 2006 13:04:57 -0400
Subject: [yarv-dev-en:149] Fixnum -> Bignum Conversion

ML: yarv-dev-en quickml.atdot.net
New Member: beng@j...

$ uname -a
Darwin pp1 8.7.0 Darwin Kernel Version 8.7.0: Fri May 26 15:20:53 PDT  
2006; root:xnu-792.6.76.obj~1/RELEASE_PPC Power Macintosh powerpc

$ cat numtest.rb
temp = 2**30 - 5
5.times do
         temp += 1
         print temp, " ", temp.class, "\n"
end

$ ./ruby-yarv -v numtest.rb
ruby 2.0.0 (Base: Ruby 1.9.0 2006-04-08) [powerpc-darwin8.7.0]
YARVCore 0.4.1 Rev: 528 (2006-08-05) [opts: [direct threaded code]  
[inline method cache] ]
1073741820 Fixnum
1073741821 Fixnum
1073741822 Fixnum
1073741823 Fixnum
6 Fixnum

This problem only happens when doing small increments, large ones  
work fine.

$ cat numtest2.rb
temp = 2
5.times do
         temp **= 2
         print temp, " ", temp.class, "\n"
end

  $ ./ruby-yarv -v numtest2.rb
ruby 2.0.0 (Base: Ruby 1.9.0 2006-04-08) [powerpc-darwin8.7.0]
YARVCore 0.4.1 Rev: 528 (2006-08-05) [opts: [direct threaded code]  
[inline method cache] ]
4 Fixnum
16 Fixnum
256 Fixnum
65536 Fixnum
4294967296 Bignum

Using the Ruby that comes with OS X 10.4

$ ruby -v numtest.rb
ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0]
1073741820 Fixnum
1073741821 Fixnum
1073741822 Fixnum
1073741823 Fixnum
1073741824 Bignum

Setting #define OPT_SPECIALISED_INSTRUCTION  0 (default is 1) in  
vm_opts.h seems to fix problem.

$ ./ruby-yarv -v numtest.rb
ruby 2.0.0 (Base: Ruby 1.9.0 2006-04-08) [powerpc-darwin8.7.0]
YARVCore 0.4.1 Rev: 528 (2006-08-05) [opts: [direct threaded code]  
[inline method cache] ]
1073741820 Fixnum
1073741821 Fixnum
1073741822 Fixnum
1073741823 Fixnum
1073741824 Bignum

Is it a problem just with OS X or maybe PPC computers?

--
ML: yarv-dev-en quickml.atdot.net
Info: http://www.atdot.net/~ko1/quickml

How to unsubscribe from the ML:
- Just send an empty message to <yarv-dev-en quickml.atdot.net>.
- Or, if you cannot send an empty message for some reason,
  please send a message just saying 'unsubscribe' to <yarv-dev-en quickml.atdot.net>.
  (e.g., hotmail's advertisement, signature, etc.)

Members of <yarv-dev-en quickml.atdot.net>:
ko1@a...
nohmad@g...
surrender_it@y...
tom@i...
wilsonb@g...
mfp@a...
curt.hibbs@g...
tsuraan@t...
kero@c...
why@w...
joaopedrosa@g...
grahamamacdonald@g...
adam.shelly@g...
gclryd-yarv-dev-en@m...
brixen@g...
jeffrey.dik@m...
rubyzbibd@u...
heidegger101@g...
klaus_momberger@y...
kashia@v...
chneukirchen@g...
aamine@l...
emiel@r...
kig@m...
pjpizza@r...
ksruby@g...
zn@m...
chris.a.williams@g...
eric@e...
gzoller@g...
ruby-forum-incoming@a...
diving@x...
steven@l...
emk.lists@g...
znmeb@c...
meinrad.recheis@g...
gerardo.santana@g...
carl.lerche@v...
drbrain@s...
james.britt@g...
joern-ml1@m...
sauer@b...
mark-ruby@a...
krisleech@i...
stephen.bannasch@g...
cies.breijs@g...
rgl@r...
nitayj@g...
xennocide@y...
slaytanic@g...
mental@r...
s450r1@g...
stephanwehner@g...
dudley@m...
shanko_date@y...
yuesefa@g...
ville.mattila@s...
beng@j...

[前][次][番号順一覧][スレッド一覧][生データ]

->     149 2006-08-15 02:04 [beng jlab.org       ] Fixnum -> Bignum Conversion             
       150 2006-08-15 15:12 ┗[ko1 atdot.net       ]