#DOCUMENTATION by Stefan Reise
class: Number class
comment/format in:
#readFrom:decimalPointCharacter:
#readFrom:onError:
--- a/Number.st Tue Dec 17 14:42:23 2019 +0100
+++ b/Number.st Tue Dec 17 14:43:08 2019 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"
COPYRIGHT (c) 1988 by Claus Gittinger
All Rights Reserved
@@ -367,11 +369,13 @@
decimalPointCharacters:(decimalPointCharacter asString)
"
+ Number readFrom:'0' decimalPointCharacter:$.
Number readFrom:'123.456' decimalPointCharacter:$.
Number readFrom:'123,456' decimalPointCharacter:$,
"
"Created: / 21-07-2019 / 13:09:52 / Claus Gittinger"
+ "Modified (comment): / 17-12-2019 / 14:42:47 / Stefan Reise"
!
readFrom:aStringOrStream decimalPointCharacter:decimalPointCharacter onError:exceptionBlock
@@ -428,7 +432,7 @@
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).
+ 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.
@@ -545,7 +549,7 @@
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).
+ 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.
@@ -750,7 +754,7 @@
scale:(scale ? mantissaAndScale third).
].
] ifFalse:[
- (nextChar == $×) ifTrue:[
+ (nextChar == $×) ifTrue:[
(((nextChar := str nextPeek) == $1)
and:[ ((nextChar := str nextPeek) == $0) ]
) ifTrue:[
@@ -884,9 +888,9 @@
See #fromString: , which is more strict and does not allow garbage at the end."
^ self
- readFrom:aStringOrStream
- decimalPointCharacters:(self decimalPointCharactersForReading)
- onError:exceptionBlock
+ readFrom:aStringOrStream
+ decimalPointCharacters:(self decimalPointCharactersForReading)
+ onError:exceptionBlock
"
Number readFrom:(ReadStream on:'54.32e-01')
@@ -897,6 +901,7 @@
Number readFrom:'16rAAAAFFFFAAAAFFFF'
Number readFrom:'0.000001'
'+00000123.45' asNumber
+ Number readFrom:'0'
Number readFrom:'99s'
Number readFrom:'99.00s'
Number readFrom:'99.0000000s'
@@ -915,6 +920,8 @@
DecimalPointCharactersForReading := #( $. ).
Number readFrom:'99,00'
"
+
+ "Modified (comment): / 17-12-2019 / 14:42:57 / Stefan Reise"
!
readSmalltalkSyntaxFrom:aStream