Ticket #748 (new defect)
32bit Number Limit and Conversion
| Reported by: | lp@… | Owned by: | lsansonetti@… |
|---|---|---|---|
| Priority: | major | Milestone: | MacRuby Later |
| Component: | MacRuby | Keywords: | 32bit number |
| Cc: |
Description (last modified by martinlagardette@…) (diff)
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
Change History
Note: See
TracTickets for help on using
tickets.

