Integer.st
changeset 15841 7c222b07168f
parent 15775 94bd832a355e
child 15902 873997dcf4cf
child 18112 0d7ac9096619
--- a/Integer.st	Mon Dec 02 20:06:35 2013 +0100
+++ b/Integer.st	Mon Dec 02 21:00:24 2013 +0100
@@ -758,6 +758,8 @@
     "Modified: / 15.11.1999 / 20:35:20 / cg"
 ! !
 
+
+
 !Integer class methodsFor:'class initialization'!
 
 initialize
@@ -818,6 +820,7 @@
     "
 ! !
 
+
 !Integer class methodsFor:'prime numbers'!
 
 flushPrimeCache
@@ -1140,6 +1143,7 @@
     ^ self == Integer
 ! !
 
+
 !Integer methodsFor:'Compatibility-Dolphin'!
 
 & aNumber
@@ -1663,22 +1667,26 @@
 
 "/    ^ -1 - self
 
-    |n "{ Class: SmallInteger }"
-     result byte|
+    |n      "{ Class: SmallInteger }"
+     byte   "{ Class: SmallInteger }"
+     result|
 
     n := self digitLength.
     result := self class basicNew numberOfDigits:n.
 
     1 to:n do:[:index |
         byte := self digitAt:index.
-        result digitAt:index put:(byte bitInvert bitAnd:16rFF).
+        byte := byte bitInvert bitAnd:16rFF.
+        result digitAt:index put:byte.
     ].
-    (byte == 255 or:[n <= SmallInteger maxBytes]) ifTrue:[
+    (byte == 0 or:[n <= SmallInteger maxBytes]) ifTrue:[
+        "if last byte is zero we can normalize"
         ^ result compressed
     ].
     ^ result
 
      "
+      16rff bitInvert bitAnd:16rff
       16rffffffff bitInvert
       16rff00ff00 bitInvert hexPrintString
      "
@@ -4325,6 +4333,7 @@
     "Created: / 09-01-2012 / 17:18:06 / cg"
 ! !
 
+
 !Integer methodsFor:'special modulu arithmetic'!
 
 add_32:anInteger
@@ -4942,9 +4951,9 @@
 
     "throw off low nbits(modulus)"
 
-    e := (aNumber bitShift:shift).
+    e := aNumber bitShift:shift.
     e := e * reciprocal.
-    e := (e bitShift:shift).
+    e := e bitShift:shift.
     e := e * modulus.
     e := aNumber - e.
 
@@ -4979,7 +4988,7 @@
 
      m := 123456789901398721398721931729371293712943794254034548369328469438562948623498659238469234659823469823658423659823658.
      Time millisecondsToRun:[
-        1000 timesRepeat:[
+        100000 timesRepeat:[
             874928459437598375937451931729371293712943794254034548369328469438562948623498659238469234659823469823658423659823658 \\ m
         ]
      ]
@@ -4990,7 +4999,7 @@
 
      m := self new modulus:123456789901398721398721931729371293712943794254034548369328469438562948623498659238469234659823469823658423659823658.
      Time millisecondsToRun:[
-        1000 timesRepeat:[
+        100000 timesRepeat:[
             m modulusOf:874928459437598375937451931729371293712943794254034548369328469438562948623498659238469234659823469823658423659823658.
         ]
      ]
@@ -5011,11 +5020,11 @@
 !Integer class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Integer.st,v 1.287 2013-09-30 10:44:21 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Integer.st,v 1.288 2013-12-02 20:00:24 stefan Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/Integer.st,v 1.287 2013-09-30 10:44:21 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Integer.st,v 1.288 2013-12-02 20:00:24 stefan Exp $'
 ! !