--- a/FixedPoint.st Fri Jan 10 19:43:15 1997 +0100
+++ b/FixedPoint.st Fri Jan 10 19:55:31 1997 +0100
@@ -207,25 +207,6 @@
"Return the number of places of significance that is carried by the receiver."
^ scale
-!
-
-withScale:newScale
- "Return a copy of the receiver, with newScale number of post-decimal
- digits"
-
- ^ self class
- numerator:numerator
- denominator:denominator
- scale:newScale
-
- "
- (Fixed fromString:'12345.12345') withScale:2
-
- ((Fixed fromString:'0.33333333')
- +
- (Fixed fromString:'0.33333333')
- ) withScale:2
- "
! !
!FixedPoint methodsFor:'arithmetic'!
@@ -562,10 +543,32 @@
!FixedPoint methodsFor:'coercing & converting'!
asFixedPoint
- "return the receiver as a fixedPoint number"
+ "return the receiver as a fixedPoint number - thats the receiver itself"
^ self
+ "Modified: 10.1.1997 / 19:53:14 / cg"
+!
+
+asFixedPoint:newScale
+ "Return a copy of the receiver, with newScale number of post-decimal
+ digits"
+
+ ^ self class
+ numerator:numerator
+ denominator:denominator
+ scale:newScale
+
+ "
+ (FixedPoint fromString:'12345.12345') asFixedPoint:2
+
+ ((FixedPoint fromString:'0.33333333')
+ +
+ (FixedPoint fromString:'0.33333333')
+ ) asFixedPoint:2
+ "
+
+ "Modified: 10.1.1997 / 19:52:25 / cg"
!
asFraction
@@ -609,6 +612,24 @@
1.0 asShortFloat + (FixedPoint fromString:'1.001')
1 asLargeInteger + (FixedPoint fromString:'1.001')
"
+!
+
+withScale:newScale
+ "Return a copy of the receiver, with newScale number of post-decimal
+ digits"
+
+ ^ self asFixedPoint:newScale
+
+ "
+ (FixedPoint fromString:'12345.12345') withScale:2
+
+ ((FixedPoint fromString:'0.33333333')
+ +
+ (FixedPoint fromString:'0.33333333')
+ ) withScale:2
+ "
+
+ "Modified: 10.1.1997 / 19:52:54 / cg"
! !
!FixedPoint methodsFor:'double dispatching'!
@@ -823,5 +844,5 @@
!FixedPoint class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/FixedPoint.st,v 1.5 1996-11-05 19:45:04 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/FixedPoint.st,v 1.6 1997-01-10 18:55:31 cg Exp $'
! !
--- a/Fraction.st Fri Jan 10 19:43:15 1997 +0100
+++ b/Fraction.st Fri Jan 10 19:55:31 1997 +0100
@@ -336,6 +336,24 @@
"Created: 5.11.1996 / 15:15:54 / cg"
!
+asFixedPoint:scale
+ "return the receiver as fixedPoint number, with the given number
+ of post-decimal-point digits."
+
+ ^ FixedPoint numerator:numerator denominator:denominator scale:scale
+
+ "
+ (1/2) asFixedPoint:2
+ (1/3) asFixedPoint:2
+ (1/3) asFixedPoint:5
+ (2/3) asFixedPoint:2
+ (2/3) asFixedPoint:5
+ "
+
+ "Created: 5.11.1996 / 15:15:54 / cg"
+ "Modified: 10.1.1997 / 19:54:50 / cg"
+!
+
asFloat
"return a float with (approximately) my value"
@@ -630,6 +648,6 @@
!Fraction class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Fraction.st,v 1.35 1996-11-05 18:39:52 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Fraction.st,v 1.36 1997-01-10 18:55:08 cg Exp $'
! !
Fraction initialize!