#REFACTORING by cg
authorClaus Gittinger <cg@exept.de>
Fri, 25 Aug 2017 12:38:25 +0200
changeset 22212 9a10518551e1
parent 22211 8fb52fc26e1a
child 22213 8b482a0c44a1
#REFACTORING by cg class: LimitedPrecisionReal changed: #asTrueFraction #exponent #mantissa class: LimitedPrecisionReal class changed: #fromInteger: #fromNumerator:denominator:
LimitedPrecisionReal.st
--- a/LimitedPrecisionReal.st	Fri Aug 25 12:31:37 2017 +0200
+++ b/LimitedPrecisionReal.st	Fri Aug 25 12:38:25 2017 +0200
@@ -223,7 +223,7 @@
         delta > 0 ifTrue: [
             completeAbsVal := absVal.
             "eliminate insignificant/trailing bits"
-            absVal := absVal bitShift: delta negated.
+            absVal := absVal rightShift: delta.
             "inexact := trailingBits ~= 0.
              Round to nearest even"
             (completeAbsVal bitAt:delta) ~= 0 ifTrue:[
@@ -282,7 +282,7 @@
      self assert: 16r1FFFFFFFFFFFF0800 asDouble = 16r1FFFFFFFFFFFF0000 asDouble.
     "
 
-    "Modified (comment): / 15-06-2017 / 09:30:30 / cg"
+    "Modified: / 25-08-2017 / 12:34:44 / cg"
 !
 
 fromLimitedPrecisionReal:anLPReal
@@ -327,7 +327,7 @@
     exponent := ha - hb - precision - 1.
     exponent > 0
         ifTrue: [b := b bitShift: exponent]
-        ifFalse: [a := a bitShift: exponent negated].
+        ifFalse: [a := a rightShift: exponent].
     q := a quo: b.
     r := a - (q * b).
     hq := q highBit.
@@ -380,6 +380,8 @@
             ].
         ]
     "
+
+    "Modified: / 25-08-2017 / 12:34:55 / cg"
 !
 
 new:aNumber
@@ -1098,7 +1100,7 @@
 
     " Extract the sign and the biased exponent "
     sign := (shifty bitAt:numBits+1) == 0 ifTrue: [1] ifFalse: [-1].
-    expPart := (shifty bitShift:numBitsInMantissa negated) bitAnd: maskExponent.
+    expPart := (shifty rightShift:numBitsInMantissa) bitAnd: maskExponent.
 
     " Extract fractional part; answer 0 if this is a true 0.0 value "
     fractionPart := shifty bitAnd:maskMantissa.
@@ -1118,16 +1120,16 @@
       the number of trailing zero bits in the fraction to minimize
       the (huge) time otherwise spent in #gcd: of fraction handling code."
     exp negative ifTrue: [
-        result := sign * (fraction bitShift: exp negated) 
+        result := sign * (fraction rightShift: exp) 
     ] ifFalse:[
         zeroBitsCount := fraction lowBit - 1.
         exp := exp - zeroBitsCount.
         exp <= 0 ifTrue: [
             zeroBitsCount := zeroBitsCount + exp.
-            result := sign * (fraction bitShift:zeroBitsCount negated) 
+            result := sign * (fraction rightShift:zeroBitsCount) 
         ] ifFalse: [
             result := Fraction
-                    numerator: (sign * (fraction bitShift: zeroBitsCount negated))
+                    numerator: (sign * (fraction rightShift: zeroBitsCount))
                     denominator: (1 bitShift:exp) 
         ] 
     ].
@@ -1152,6 +1154,8 @@
      LongFloat infinity asTrueFraction          
      LongFloat negativeInfinity asTrueFraction 
     "
+
+    "Modified: / 25-08-2017 / 12:34:08 / cg"
 ! !
 
 !LimitedPrecisionReal methodsFor:'comparing'!
@@ -1244,7 +1248,6 @@
 ! !
 
 
-
 !LimitedPrecisionReal methodsFor:'printing & storing'!
 
 printOn:aStream
@@ -1342,7 +1345,7 @@
     ].
 
     " Extract the sign and the biased exponent "
-    expPart := (shifty bitShift:numBitsInMantissa negated) bitAnd: maskExponent.
+    expPart := (shifty rightShift:numBitsInMantissa) bitAnd: maskExponent.
 
     " Extract fractional part; answer 0 if this is a true 0.0 value "
     fractionPart := shifty bitAnd:maskMantissa.
@@ -1367,7 +1370,7 @@
      0.00000011111 exponent2  -23 
     "
 
-    "Modified (comment): / 20-06-2017 / 11:34:29 / cg"
+    "Modified: / 25-08-2017 / 12:34:23 / cg"
 !
 
 fractionalPart
@@ -1418,7 +1421,7 @@
     ].
 
     " Extract the sign and the biased exponent "
-    expPart := (shifty bitShift:numBitsInMantissa negated) bitAnd: maskExponent.
+    expPart := (shifty rightShift:numBitsInMantissa) bitAnd: maskExponent.
 
     " Extract fractional part; answer 0 if this is a true 0.0 value "
     fractionPart := shifty bitAnd:maskMantissa.
@@ -1432,6 +1435,7 @@
     "
 
     "Created: / 20-06-2017 / 11:36:51 / cg"
+    "Modified: / 25-08-2017 / 12:34:34 / cg"
 !
 
 precision
@@ -1447,7 +1451,6 @@
    ^ 0
 ! !
 
-
 !LimitedPrecisionReal methodsFor:'testing'!
 
 isFinite