class: FixedPoint
authorClaus Gittinger <cg@exept.de>
Sat, 07 Feb 2015 17:16:28 +0100
changeset 17445 1753d81dbc4c
parent 17444 c8bd028d774a
child 17446 2f33cc5a4814
class: FixedPoint changed: #readFrom:decimalPointCharacters:onError:
FixedPoint.st
--- a/FixedPoint.st	Sat Feb 07 17:07:04 2015 +0100
+++ b/FixedPoint.st	Sat Feb 07 17:16:28 2015 +0100
@@ -13,6 +13,8 @@
 "
 "{ Package: 'stx:libbasic' }"
 
+"{ NameSpace: Smalltalk }"
+
 Fraction subclass:#FixedPoint
 	instanceVariableNames:'scale'
 	classVariableNames:'PI_1000 PrintTruncated'
@@ -214,7 +216,7 @@
      If an error occurs during conversion, return the result
      from evaluating exceptionBlock"
 
-    | aStream sign integerPart fractionStream char fractionPart scale |
+    | aStream sign integerPart fractionStream char fractionPart scale nextChar |
 
     aStream := aStringOrStream readStream.
 
@@ -225,8 +227,8 @@
         sign := 1
     ].
 
-    (aStream atEnd or:[aStream peek isLetter]) ifTrue: [^ exceptionBlock value].
-    (decimalPointCharacters includes:aStream peek) ifTrue:[
+    (aStream atEnd or:[(nextChar := aStream peek) isLetter]) ifTrue: [^ exceptionBlock value].
+    (decimalPointCharacters includes:nextChar) ifTrue:[
         "/ no integer part
         integerPart := 0.
         aStream next.
@@ -255,13 +257,18 @@
         scale:scale
 
     "
-     FixedPoint readFrom:'1.00' 
+     FixedPoint readFrom:'1.00'    
      FixedPoint readFrom:'123.456'  
-     FixedPoint readFrom:'123,456' decimalPointCharacters:','
-     FixedPoint readFrom:'-123.456' 
-     FixedPoint readFrom:'123' 
+     FixedPoint readFrom:'123,456' decimalPointCharacters:',' 
+     FixedPoint readFrom:'-123.456'     
+     FixedPoint readFrom:'123'          
      FixedPoint readFrom:'-123' 
-     FixedPoint readFrom:'-123.abcd' onError:[47.5] 
+
+     FixedPoint readFromString:'-123.abcd' onError:[47.5]  
+     FixedPoint readFromString:'-1a.bcd' onError:[47.5]  
+     FixedPoint readFromString:'foot' onError:['bad fixedpoint'] 
+
+     FixedPoint readFrom:'-123.abcd' onError:[47.5]  
      FixedPoint readFrom:'-1a.bcd' onError:[47.5] 
      FixedPoint readFrom:'foot' onError:['bad fixedpoint'] 
     "
@@ -289,7 +296,6 @@
     "
 ! !
 
-
 !FixedPoint class methodsFor:'printing control'!
 
 printTruncated
@@ -315,7 +321,6 @@
     ^ $s
 ! !
 
-
 !FixedPoint methodsFor:'accessing'!
 
 scale
@@ -1292,7 +1297,6 @@
     "Modified: 12.4.1997 / 11:22:02 / cg"
 ! !
 
-
 !FixedPoint methodsFor:'testing'!
 
 isFixedPoint
@@ -1352,10 +1356,10 @@
 !FixedPoint class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/FixedPoint.st,v 1.47 2014-11-13 21:49:07 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/FixedPoint.st,v 1.48 2015-02-07 16:16:28 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/FixedPoint.st,v 1.47 2014-11-13 21:49:07 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/FixedPoint.st,v 1.48 2015-02-07 16:16:28 cg Exp $'
 ! !