Define #decimalPrecision, #epsilon
authorStefan Vogel <sv@exept.de>
Tue, 11 Jun 2002 23:44:10 +0200
changeset 6575 b07cd54c4375
parent 6574 788f5a36dcb1
child 6576 c28cdeb0bfb0
Define #decimalPrecision, #epsilon
LimitedPrecisionReal.st
--- a/LimitedPrecisionReal.st	Tue Jun 11 23:43:11 2002 +0200
+++ b/LimitedPrecisionReal.st	Tue Jun 11 23:44:10 2002 +0200
@@ -78,6 +78,17 @@
 
 !LimitedPrecisionReal class methodsFor:'constants & defaults'!
 
+decimalPrecision
+    "return the precision (the number of decimal digits)"
+
+    ^ (self precision / (10.0 log:self radix)) floor
+
+    "
+     Float decimalPrecision
+     ShortFloat decimalPrecision
+    "
+!
+
 e
     "return the closest approximation of the irrational number e"
 
@@ -105,7 +116,14 @@
 epsilon
     "return the maximum relative spacing"
 
-    ^ self radix raisedTo:(1- self precision)
+    ^ self radix asFloat raisedTo:(1 - self precision)
+
+    "
+      ShortFloat epsilon
+      Float epsilon
+      LongFloat epsilon
+    "
+
 
     "Created: / 7.9.2001 / 14:06:41 / cg"
 !
@@ -116,7 +134,6 @@
     self subclassResponsibility
 
     "Created: / 7.9.2001 / 14:06:56 / cg"
-    "Modified: / 7.9.2001 / 14:07:15 / cg"
 !
 
 fmin
@@ -125,7 +142,6 @@
     self subclassResponsibility
 
     "Created: / 7.9.2001 / 14:07:06 / cg"
-    "Modified: / 7.9.2001 / 14:07:19 / cg"
 !
 
 pi
@@ -133,7 +149,6 @@
 
     self subclassResponsibility
 
-    "Modified: / 7.9.2001 / 14:05:02 / cg"
     "Created: / 7.9.2001 / 14:07:35 / cg"
 !
 
@@ -142,7 +157,6 @@
 
     self subclassResponsibility
 
-    "Modified: / 7.9.2001 / 14:05:02 / cg"
     "Created: / 7.9.2001 / 14:07:58 / cg"
 !
 
@@ -151,7 +165,6 @@
 
     self subclassResponsibility
 
-    "Modified: / 7.9.2001 / 14:05:02 / cg"
     "Created: / 7.9.2001 / 14:08:20 / cg"
 ! !
 
@@ -665,6 +678,6 @@
 !LimitedPrecisionReal class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/LimitedPrecisionReal.st,v 1.43 2001-11-16 13:21:26 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/LimitedPrecisionReal.st,v 1.44 2002-06-11 21:44:10 stefan Exp $'
 ! !
 LimitedPrecisionReal initialize!