[MacRuby-devel] [MacRuby] #748: 32bit Number Limit and Conversion
MacRuby
ruby-noreply at macosforge.org
Mon Jun 14 15:00:28 PDT 2010
#748: 32bit Number Limit and Conversion
-----------------------------+----------------------------------------------
Reporter: lp@… | Owner: lsansonetti@…
Type: defect | Status: new
Priority: major | Milestone: MacRuby 0.7
Component: MacRuby | Keywords: 32bit number
-----------------------------+----------------------------------------------
there seems to be a bug in the 32bit release of 0.6 with numbers
arch -arch i386 macirb --simple-prompt
>> 0x44485250
# reality check
=> 1145590352
>> NSNumber.numberWithInt(0x44485250) # then
see all 32 NSNumber are weird...
=> 71848528
>> NSNumber.numberWithFloat(0x44485250)
=> 1145590272.0
>> NSNumber.numberWithInt(1145590352)
=> 71848528
>> NSNumber.numberWithFloat(1145590352)
=> 1145590272.0
versus:
arch -arch x86_64 macirb --simple-prompt
>> 0x44485250
# reality check
=> 1145590352
>> NSNumber.numberWithInt(0x44485250)
=> 1145590352
>> NSNumber.numberWithFloat(0x44485250)
=> 1145590400.0
>> NSNumber.numberWithInt(1145590352)
=> 1145590352
>> NSNumber.numberWithFloat(1145590352.0) # this is
weird again...
=> 1145590400.0
to look a bit further, the bug turning point seems to be here for the
32bit release:
>> NSNumber.numberWithInt(536870910)
=> 536870910
>> NSNumber.numberWithInt(536870911)
=> 536870911
>> NSNumber.numberWithInt(536870912)
=> -536870912
>> NSNumber.numberWithInt(536870913)
=> -536870911
and here in the 64 bit:
>> NSNumber.numberWithInt(2147483646)
=> 2147483646
>> NSNumber.numberWithInt(2147483647)
=> 2147483647
>> NSNumber.numberWithInt(2147483648)
=> -2147483648
>> NSNumber.numberWithInt(2147483649)
=> -2147483647
also an other detail:
32bit turning point:
>> 536870911 / 16
=> 33554431
64bit turning point:
>> 2147483647 / 64
=> 33554431
--
Ticket URL: <http://www.macruby.org/trac/ticket/748>
MacRuby <http://macruby.org/>
More information about the MacRuby-devel
mailing list