--- a/Number.st Fri Mar 24 12:53:57 2000 +0100
+++ b/Number.st Fri Mar 24 12:54:44 2000 +0100
@@ -1,6 +1,6 @@
"
COPYRIGHT (c) 1988 by Claus Gittinger
- All Rights Reserved
+ All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
@@ -22,7 +22,7 @@
copyright
"
COPYRIGHT (c) 1988 by Claus Gittinger
- All Rights Reserved
+ All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
@@ -38,12 +38,12 @@
abstract superclass for all kinds of numbers
[author:]
- Claus Gittinger
+ Claus Gittinger
[see also:]
- Integer LargeInteger SmallInteger
- LimitedPrecisionReal Float ShortFloat
- Fraction FixedPoint
+ Integer LargeInteger SmallInteger
+ LimitedPrecisionReal Float ShortFloat
+ Fraction FixedPoint
"
! !
@@ -83,79 +83,79 @@
|value|
ErrorSignal handle:[:ex |
- ^ exceptionBlock value
+ ^ exceptionBlock value
] do:[
- |str nextChar radix negative signExp|
+ |str nextChar radix negative signExp|
- str := aStringOrStream readStream.
+ str := aStringOrStream readStream.
- nextChar := str skipSeparators.
- nextChar isNil ifTrue:[^ exceptionBlock value].
+ nextChar := str skipSeparators.
+ nextChar isNil ifTrue:[^ exceptionBlock value].
- (nextChar == $-) ifTrue:[
- negative := true.
- str next.
- nextChar := str peekOrNil
- ] ifFalse:[
- negative := false.
- (nextChar == $+) ifTrue:[
- str next.
- nextChar := str peekOrNil
- ]
- ].
- (nextChar isDigit or:[nextChar == $.]) ifFalse:[
- ^ exceptionBlock value.
+ (nextChar == $-) ifTrue:[
+ negative := true.
+ str next.
+ nextChar := str peekOrNil
+ ] ifFalse:[
+ negative := false.
+ (nextChar == $+) ifTrue:[
+ str next.
+ nextChar := str peekOrNil
+ ]
+ ].
+ (nextChar isDigit or:[nextChar == $.]) ifFalse:[
+ ^ exceptionBlock value.
"/ value := super readFrom:str.
"/ negative ifTrue:[value := value negated].
"/ ^ value
- ].
- nextChar == $. ifTrue:[
- radix := 10.
- value := 0.0.
- ] ifFalse:[
- value := Integer readFrom:str radix:10.
- nextChar := str peekOrNil.
- ((nextChar == $r) or:[ nextChar == $R]) ifTrue:[
- str next.
- radix := value.
- value := Integer readFrom:str radix:radix.
- ] ifFalse:[
- radix := 10
- ].
- ].
+ ].
+ nextChar == $. ifTrue:[
+ radix := 10.
+ value := 0.0.
+ ] ifFalse:[
+ value := Integer readFrom:str radix:10.
+ nextChar := str peekOrNil.
+ ((nextChar == $r) or:[ nextChar == $R]) ifTrue:[
+ str next.
+ radix := value.
+ value := Integer readFrom:str radix:radix.
+ ] ifFalse:[
+ radix := 10
+ ].
+ ].
- (nextChar == $.) ifTrue:[
- str next.
- nextChar := str peekOrNil.
- (nextChar notNil and:[nextChar isDigitRadix:radix]) ifTrue:[
- value := value asFloat
- + (Number readMantissaFrom:str radix:radix).
- nextChar := str peekOrNil
- ]
- ].
- ((nextChar == $e) or:[nextChar == $E]) ifTrue:[
- str next.
- nextChar := str peekOrNil.
- signExp := 1.
- (nextChar == $+) ifTrue:[
- str next.
- nextChar := str peekOrNil.
- ] ifFalse:[
- (nextChar == $-) ifTrue:[
- str next.
- nextChar := str peekOrNil.
- signExp := -1
- ]
- ].
- (nextChar notNil and:[(nextChar isDigitRadix:radix)]) ifTrue:[
- value := value asFloat
- * (10.0 raisedToInteger:
- ((Integer readFrom:str radix:radix) * signExp))
- ]
- ].
- negative ifTrue:[
- value := value negated
- ].
+ (nextChar == $.) ifTrue:[
+ str next.
+ nextChar := str peekOrNil.
+ (nextChar notNil and:[nextChar isDigitRadix:radix]) ifTrue:[
+ value := value asFloat
+ + (Number readMantissaFrom:str radix:radix).
+ nextChar := str peekOrNil
+ ]
+ ].
+ ((nextChar == $e) or:[nextChar == $E]) ifTrue:[
+ str next.
+ nextChar := str peekOrNil.
+ signExp := 1.
+ (nextChar == $+) ifTrue:[
+ str next.
+ nextChar := str peekOrNil.
+ ] ifFalse:[
+ (nextChar == $-) ifTrue:[
+ str next.
+ nextChar := str peekOrNil.
+ signExp := -1
+ ]
+ ].
+ (nextChar notNil and:[(nextChar isDigitRadix:radix)]) ifTrue:[
+ value := value asFloat
+ * (10.0 raisedToInteger:
+ ((Integer readFrom:str radix:radix) * signExp))
+ ]
+ ].
+ negative ifTrue:[
+ value := value negated
+ ].
].
^ value.
@@ -212,22 +212,22 @@
|msg|
msg := MessageSend
- receiver:someNumber
- selector:sel
- arguments:(Array with:arg).
+ receiver:someNumber
+ selector:sel
+ arguments:(Array with:arg).
^ (self perform:aSignalSymbol)
- raiseRequestWith:msg
- errorString:text
- in:thisContext sender
+ raiseRequestWith:msg
+ errorString:text
+ in:thisContext sender
"
Number
- raise:#domainErrorSignal
- receiver:1.0
- selector:#sin
- arg:nil
- errorString:'foo bar test'
+ raise:#domainErrorSignal
+ receiver:1.0
+ selector:#sin
+ arg:nil
+ errorString:'foo bar test'
"
!
@@ -239,22 +239,22 @@
|msg|
msg := MessageSend
- receiver:someNumber
- selector:sel
- arguments:argArray.
+ receiver:someNumber
+ selector:sel
+ arguments:argArray.
^ (self perform:aSignalSymbol)
- raiseRequestWith:msg
- errorString:text
- in:thisContext sender
+ raiseRequestWith:msg
+ errorString:text
+ in:thisContext sender
"
Number
- raise:#domainErrorSignal
- receiver:1.0
- selector:#sin
- arg:nil
- errorString:'foo bar test'
+ raise:#domainErrorSignal
+ receiver:1.0
+ selector:#sin
+ arg:nil
+ errorString:'foo bar test'
"
!
@@ -266,21 +266,21 @@
|msg|
msg := MessageSend
- receiver:someNumber
- selector:sel
- arguments:#().
+ receiver:someNumber
+ selector:sel
+ arguments:#().
^ (self perform:aSignalSymbol)
- raiseRequestWith:msg
- errorString:text
- in:thisContext sender
+ raiseRequestWith:msg
+ errorString:text
+ in:thisContext sender
"
Number
- raise:#domainErrorSignal
- receiver:1.0
- selector:#foo
- errorString:'foo bar test'
+ raise:#domainErrorSignal
+ receiver:1.0
+ selector:#foo
+ errorString:'foo bar test'
"
! !
@@ -297,10 +297,10 @@
factor := 1.0 / radix.
nextChar := aStream peekOrNil.
[nextChar notNil and:[nextChar isDigitRadix:radix]] whileTrue:[
- value := value + (nextChar digitValue * factor).
- factor := factor / radix.
- aStream next.
- nextChar := aStream peekOrNil
+ value := value + (nextChar digitValue * factor).
+ factor := factor / radix.
+ aStream next.
+ nextChar := aStream peekOrNil
].
^ value
@@ -361,20 +361,20 @@
/*
* I cannot tell if this special code is worth anything
*/
- if (__CanDoQuickNew(sizeof(struct __point))) { /* OBJECT ALLOCATION */
- OBJ newPoint;
- int spc;
+ if (__CanDoQuickNew(sizeof(struct __Point))) { /* OBJECT ALLOCATION */
+ OBJ newPoint;
+ int spc;
- __qCheckedAlignedNew(newPoint, sizeof(struct __point));
- __InstPtr(newPoint)->o_class = @global(Point);
- __PointInstPtr(newPoint)->p_x = self;
- __PointInstPtr(newPoint)->p_y = aNumber;
- if (! __bothSmallInteger(self, aNumber)) {
- spc = __qSpace(newPoint);
- __STORE_SPC(newPoint, aNumber, spc);
- __STORE_SPC(newPoint, self, spc);
- }
- RETURN ( newPoint );
+ __qCheckedAlignedNew(newPoint, sizeof(struct __Point));
+ __InstPtr(newPoint)->o_class = @global(Point);
+ __PointInstPtr(newPoint)->p_x = self;
+ __PointInstPtr(newPoint)->p_y = aNumber;
+ if (! __bothSmallInteger(self, aNumber)) {
+ spc = __qSpace(newPoint);
+ __STORE_SPC(newPoint, aNumber, spc);
+ __STORE_SPC(newPoint, self, spc);
+ }
+ RETURN ( newPoint );
}
%}
.
@@ -397,15 +397,15 @@
%{ /* NOCONTEXT */
- if (__CanDoQuickNew(sizeof(struct __point))) { /* OBJECT ALLOCATION */
- OBJ newPoint;
+ if (__CanDoQuickNew(sizeof(struct __Point))) { /* OBJECT ALLOCATION */
+ OBJ newPoint;
- __qCheckedAlignedNew(newPoint, sizeof(struct __point));
- __InstPtr(newPoint)->o_class = @global(Point);
- __PointInstPtr(newPoint)->p_x = self;
- __PointInstPtr(newPoint)->p_y = self;
- __STORE(newPoint, self);
- RETURN ( newPoint );
+ __qCheckedAlignedNew(newPoint, sizeof(struct __Point));
+ __InstPtr(newPoint)->o_class = @global(Point);
+ __PointInstPtr(newPoint)->p_x = self;
+ __PointInstPtr(newPoint)->p_y = self;
+ __STORE(newPoint, self);
+ RETURN ( newPoint );
}
%}.
^ Point x:self y:self
@@ -467,8 +467,8 @@
count := self.
[count > 0] whileTrue:[
- aBlock value.
- count := count - 1
+ aBlock value.
+ count := count - 1
]
!
@@ -480,15 +480,15 @@
tmp := self.
(incr > 0) ifTrue:[
- [tmp <= stop] whileTrue:[
- aBlock value:tmp.
- tmp := tmp+incr
- ]
+ [tmp <= stop] whileTrue:[
+ aBlock value:tmp.
+ tmp := tmp+incr
+ ]
] ifFalse:[
- [tmp >= stop] whileTrue:[
- aBlock value:tmp.
- tmp := tmp+incr
- ]
+ [tmp >= stop] whileTrue:[
+ aBlock value:tmp.
+ tmp := tmp+incr
+ ]
]
!
@@ -502,23 +502,23 @@
break := [^ self].
tmp := self.
(incr > 0) ifTrue:[
- [tmp <= stop] whileTrue:[
- aBlock value:tmp value:break.
- tmp := tmp+incr
- ]
+ [tmp <= stop] whileTrue:[
+ aBlock value:tmp value:break.
+ tmp := tmp+incr
+ ]
] ifFalse:[
- [tmp >= stop] whileTrue:[
- aBlock value:tmp value:break.
- tmp := tmp+incr
- ]
+ [tmp >= stop] whileTrue:[
+ aBlock value:tmp value:break.
+ tmp := tmp+incr
+ ]
]
"
1 to:100 by:5 doWithBreak:[:index :break |
- Transcript showCR:index printString.
- index > 50 ifTrue:[
- break value
- ].
+ Transcript showCR:index printString.
+ index > 50 ifTrue:[
+ break value
+ ].
]
"
!
@@ -531,8 +531,8 @@
tmp := self.
[tmp <= stop] whileTrue:[
- aBlock value:tmp.
- tmp := tmp+1
+ aBlock value:tmp.
+ tmp := tmp+1
]
!
@@ -546,16 +546,16 @@
break := [^ self].
tmp := self.
[tmp <= stop] whileTrue:[
- aBlock value:tmp value:break.
- tmp := tmp+1
+ aBlock value:tmp value:break.
+ tmp := tmp+1
]
"
1 to:10 doWithBreak:[:index :break |
- Transcript showCR:index printString.
- index > 5 ifTrue:[
- break value
- ].
+ Transcript showCR:index printString.
+ index > 5 ifTrue:[
+ break value
+ ].
]
"
! !
@@ -655,8 +655,8 @@
snap ifTrue: [^ self]. "...or return self"
r2 := self < r1 "Nearest end of dead zone"
- ifTrue: [r1 - (detent asFloat/2)]
- ifFalse: [r1 + (detent asFloat/2)].
+ ifTrue: [r1 - (detent asFloat/2)]
+ ifFalse: [r1 + (detent asFloat/2)].
"Scale values between dead zones to fill range between multiples"
^ r1 + ((self - r2) * grid asFloat / (grid - detent))
@@ -702,5 +702,5 @@
!Number class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Number.st,v 1.58 2000-03-21 10:56:14 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Number.st,v 1.59 2000-03-24 11:54:41 cg Exp $'
! !