--- a/Number.st Wed May 14 17:05:59 2014 +0200
+++ b/Number.st Wed May 14 17:07:20 2014 +0200
@@ -236,9 +236,11 @@
nextChar := str peekOrNil.
decimalMantissa := 0.
(nextChar notNil and:[nextChar isDigitRadix:radix]) ifTrue:[
- mantissaAndScale := Number readMantissaAndScaleFrom:str radix:radix.
- value := value asFloat + (mantissaAndScale first).
- nextChar := str peekOrNil
+ |mantissa|
+ mantissaAndScale := self readMantissaAndScaleFrom:str radix:radix.
+ mantissa := mantissaAndScale first.
+ value := (mantissa coerce:value) + mantissa.
+ nextChar := str peekOrNil.
]
].
('eEdDqQ' includes:nextChar) ifTrue:[
@@ -259,7 +261,7 @@
value := value asLongFloat.
] ifFalse:[
value := value asFloat.
-"/ future: (for now, always create Doubles for Dolphin,Squeak etc. compatibility
+"/ future: (for now, always create Doubles for Dolphin,Squeak etc. compatibility)
"/ ('eE' includes:nextChar) ifTrue:[
"/ value := value asShortFloat
"/ ]
@@ -269,7 +271,7 @@
value := value * ((value class unity * 10.0) raisedToInteger:exp)
]
] ifFalse:[
- ('s' includes:nextChar) ifTrue:[
+ ('sS' includes:nextChar) ifTrue:[
str next.
nextChar := str peekOrNil.
@@ -284,12 +286,14 @@
value := FixedPoint
numerator:(intValue * denom) + (mantissaAndScale second)
denominator:denom
- scale:(scale ? mantissaAndScale last).
+ scale:(scale ? mantissaAndScale third).
].
] ifFalse:[
- value isLimitedPrecisionReal ifTrue:[
- value := value asFloat.
- ]
+ (self inheritsFrom:LimitedPrecisionReal) ifTrue:[
+ "when requesting a specific Float instance, coerce it.
+ otherwise return a value without loosing precision"
+ value := self coerce:value.
+ ].
].
].
].
@@ -322,6 +326,10 @@
Number readFrom:'.0000000q1'
Number readFrom:'.0000000f1'
Number readFrom:'.0000000e1'
+ LongFloat readFrom:'.00000001'
+ Number readFrom:'.00000000000001'
+ Number readFrom:'.001'
+ ShortFloat readFrom:'.001'
DecimalPointCharactersForReading := #( $. $, ).
Number readFrom:'99,00'
@@ -2380,10 +2388,10 @@
!Number class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Number.st,v 1.147 2014-05-07 14:32:05 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Number.st,v 1.148 2014-05-14 15:07:20 stefan Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/Number.st,v 1.147 2014-05-07 14:32:05 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Number.st,v 1.148 2014-05-14 15:07:20 stefan Exp $'
! !