--- a/Number.st Thu Jan 17 12:53:50 2019 +0100
+++ b/Number.st Fri Jan 18 14:05:49 2019 +0100
@@ -247,6 +247,8 @@
it allows for prefixed + and also allows missing fractional part after eE.
It supports 0x, 0o and 0b prefixes (hex, octal and binary)
and the regular Smalltalk radix prefix xr.
+ If also allows for strings like '1.0×1015' to be read (as 1E+15).
+
It also allows garbage after the number - i.e. it reads what it can.
See #fromString: , which is more strict and does not allow garbage at the end.
@@ -434,10 +436,22 @@
scale:(scale ? mantissaAndScale third).
].
] ifFalse:[
- (self inheritsFrom:LimitedPrecisionReal) ifTrue:[
- "when requesting a specific Float instance, coerce it.
- otherwise return a value without loosing precision"
- value := self coerce:value.
+ (nextChar == $×) ifTrue:[
+ (((nextChar := str nextPeek) == $1)
+ and:[ ((nextChar := str nextPeek) == $0) ]
+ ) ifTrue:[
+ str next.
+ exp := (Integer readFrom:str).
+ value := value * ((value class unity * 10.0) raisedToInteger:exp).
+ ] ifFalse:[
+ ^ exceptionBlock value.
+ ].
+ ] ifFalse:[
+ (self inheritsFrom:LimitedPrecisionReal) ifTrue:[
+ "when requesting a specific Float instance, coerce it.
+ otherwise return a value without loosing precision"
+ value := self coerce:value.
+ ].
].
].
].
@@ -504,6 +518,7 @@
"
"Created: / 27-10-2018 / 09:21:11 / Claus Gittinger"
+ "Modified (comment): / 18-01-2019 / 12:34:40 / Claus Gittinger"
!
readFrom:aStringOrStream decimalPointCharacters:decimalPointCharacters onError:exceptionBlock
@@ -1583,6 +1598,7 @@
"
! !
+
!Number methodsFor:'intervals'!
downTo:stop