Mantis - Squeak
Viewing Issue Advanced Details
6874 Kernel minor always 01-26-08 00:54 04-18-10 22:05
nicolas cellier  
nicolas cellier  
normal  
closed 3.10  
fixed  
none    
none trunk  
0006874: digitLogic:op:len: is not correct
(2 raisedTo: 31) negated bitAnd: (2 raisedTo: 31) negated - 1
does answer
    0
it should answer
    (2 raisedTo: 32) negated

This bug caused 0006873
In two complement (assume an infinite sequence of 1 on the left)

... 11111111 10000000 00000000 00000000 00000000
... 11111111 01111111 11111111 11111111 11111111
=>
... 11111111 00000000 00000000 00000000 00000000

Algorithm works well, but on every 8bit boundary, where a carry rz=true is not correctly taken into account.
related to 0006873closed andreas [BUG] isPowerOfTwo incorrect for some LargeNegativeInteger 
 TwoComplementDigitLogic-Test-M6874-nice.1.cs [^] (1,734 bytes) 01-26-08 01:40
 TwoComplementDigitLogic-Patch-M6874-nice.1.cs [^] (2,356 bytes) 01-26-08 01:40

Notes
(0011713)
nicolas cellier   
01-26-08 01:43   
"fix begin"
Installer mantis bug: 6874 fix:'TwoComplementDigitLogic-Patch-M6874-nice.1.cs'.
"fix test"
Installer mantis bug: 6874 fix:'TwoComplementDigitLogic-Test-M6874-nice.1.cs'.
"fix end"
(0011714)
nicolas cellier   
01-26-08 01:52   
Solution in patch.1 rely on digitAt: behaving correctly past digitLength...
It does loop until carry vanishes.
Maybe there is a simpler solution than processing this carry:
Keep original 1 to: len do: loop and add this a posteriori test:

    (rneg and: [result normalize isZero]) ifTrue: [
        result := result growby: 1.
        result digitAt: result digitLength put: 1.
    ].
    ^result normalize
(0013277)
nicolas cellier   
08-24-09 20:14   
Fixed in http://source.squeak.org/trunk/Kernel-nice.199.mcz [^]