LimitedPrecisionReal.st
changeset 2141 bba0027204fd
parent 1893 c66af5c46272
child 2388 df5e0eb88999
--- a/LimitedPrecisionReal.st	Fri Jan 10 19:55:31 1997 +0100
+++ b/LimitedPrecisionReal.st	Fri Jan 10 20:01:23 1997 +0100
@@ -148,6 +148,44 @@
 
 !LimitedPrecisionReal methodsFor:'coercion and converting'!
 
+asFixedPoint
+    "return the receiver as fixedPoint number.
+     Q: what should the scale be here ?"
+
+    ^ self asFraction asFixedPoint
+
+    "
+     0.3 asFixedPoint
+     0.5 asFixedPoint
+     (1/5) asFloat asFixedPoint 
+     (1/3) asFloat asFixedPoint 
+     (2/3) asFloat asFixedPoint 
+     (1/8) asFloat asFixedPoint
+     3.14159 asFixedPoint
+    "
+
+    "Modified: 10.1.1997 / 19:59:56 / cg"
+!
+
+asFixedPoint:scale
+    "return the receiver as fixedPoint number with the given
+     number of post-decimal-digits."
+
+    ^ self asFraction asFixedPoint:scale
+
+    "
+     0.3 asFixedPoint:3     
+     0.5 asFixedPoint:3     
+     (1/5) asFloat asFixedPoint:1  
+     (1/8) asFloat asFixedPoint:1  
+     3.14159 asFixedPoint:2       
+     3.14159 asFixedPoint:3       
+     (3.14159 asFixedPoint:2) asFixedPoint:5  
+    "
+
+    "Modified: 10.1.1997 / 19:59:42 / cg"
+!
+
 asFraction
     "return a corresponding fraction
      - notice, that 'aFract asFloat asFraction' does not always return
@@ -401,5 +439,5 @@
 !LimitedPrecisionReal class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/LimitedPrecisionReal.st,v 1.17 1996-11-05 18:38:50 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/LimitedPrecisionReal.st,v 1.18 1997-01-10 19:01:23 cg Exp $'
 ! !