'From Squeak2.8alpha of 18 January 2000 [latest update: #1873] on 28 February 2000 at 5:49:31 pm'! "Change Set: numcase-bf Date: 28 February 2000 Author: Bert Freudenberg Makes number reading independent of case"! !Character methodsFor: 'accessing' stamp: 'bf 2/28/2000 17:42'! digitValue "Answer 0-9 if the receiver is $0-$9, 10-35 if it is $A-$Z or $a-$z, and < 0 otherwise. This is used to parse literal numbers of radix 2-36." value <= $9 asciiValue ifTrue: [^value - $0 asciiValue]. (value between: $A asciiValue and: $Z asciiValue) ifTrue: [^value - $A asciiValue + 10]. (value between: $a asciiValue and: $z asciiValue) ifTrue: [^value - $a asciiValue + 10]. ^ -1! ! !Number class methodsFor: 'instance creation' stamp: 'bf 2/28/2000 17:39'! readRemainderOf: integerPart from: aStream base: base withSign: sign "Read optional fractional part and exponent, and return the final result" | value fraction fracpos | value _ integerPart. (aStream peekFor: $.) ifTrue: ["." (aStream atEnd not and: [aStream peek digitValue between: 0 and: base - 1]) ifTrue: [fracpos _ aStream position. fraction _ Integer readFrom: aStream base: base. fraction _ fraction asFloat / (base raisedTo: aStream position - fracpos). value _ value asFloat + fraction] ifFalse: ["oops - just ." aStream skip: -1. "un-gobble the period" ^ value * sign "Number readFrom: '3r-22.2'"]]. ((aStream peekFor: $e) or: [aStream peekFor: $E]) ifTrue: ["e" value _ value * (base raisedTo: (Integer readFrom: aStream))]. (value isFloat and: [value = 0.0 and: [sign = -1]]) ifTrue: [^ Float negativeZero] ifFalse: [^ value * sign]! !