--- a/Number.st Mon Jul 22 20:16:59 2019 +0200
+++ b/Number.st Mon Jul 22 20:17:41 2019 +0200
@@ -1210,14 +1210,8 @@
The integer mantissa is needed as we do not yet know the target type (could be LongFloat or even QDouble).
No whitespace is skipped."
- |nextChar value factor intMantissa scale digit scaleFactor xvalue|
-
- value := 0.
- factor := 1 / radix.
- self isAbstract ifFalse:[
- value := self zero.
- factor := self unity / (self coerce:radix).
- ].
+ |nextChar intMantissa scale digit scaleFactor value|
+
scale := 0.
scaleFactor := 1.
intMantissa := 0.
@@ -1225,29 +1219,23 @@
[nextChar notNil and:[nextChar isDigitRadix:radix]] whileTrue:[
digit := nextChar digitValue.
scaleFactor := scaleFactor * radix.
- value := value + (digit * factor).
intMantissa := (intMantissa * radix) + digit.
- factor := factor / radix.
scale := scale + 1.
- (scale > 6 and:[self isAbstract]) ifTrue:[
- factor := factor asLongFloat.
- value := value asLongFloat.
- ].
aStream next.
nextChar := aStream peekOrNil
].
self isAbstract ifFalse:[
- xvalue := (self coerce:intMantissa) / (self coerce:scaleFactor).
+ value := (self coerce:intMantissa) / (self coerce:scaleFactor).
] ifTrue:[
scale > 6 ifTrue:[
- xvalue := intMantissa asLongFloat / scaleFactor asLongFloat.
+ value := intMantissa asLongFloat / scaleFactor asLongFloat.
] ifFalse:[
- xvalue := intMantissa asFloat / scaleFactor asFloat.
+ value := intMantissa asFloat / scaleFactor asFloat.
].
].
- ^ (Array with:xvalue with:intMantissa with:scale).
+ ^ (Array with:value with:intMantissa with:scale).
"
Number readMantissaAndScaleFrom:'234' readStream radix:10.
@@ -1267,6 +1255,7 @@
"
"Modified: / 17-06-2017 / 03:03:03 / cg"
+ "Modified: / 22-07-2019 / 19:37:21 / Claus Gittinger"
!
readMantissaFrom:aStream radix:radix