Float.st
changeset 7391 55ca5a24162a
parent 7385 852e84340d2b
child 7393 23344038fa0e
--- a/Float.st	Tue Jun 17 13:51:13 2003 +0200
+++ b/Float.st	Tue Jun 17 13:51:43 2003 +0200
@@ -14,7 +14,7 @@
 
 LimitedPrecisionReal variableByteSubclass:#Float
 	instanceVariableNames:''
-	classVariableNames:'DefaultPrintFormat'
+	classVariableNames:'DefaultPrintFormat Pi E'
 	poolDictionaries:''
 	category:'Magnitude-Numbers'
 !
@@ -225,8 +225,11 @@
     DefaultPrintFormat := '.6'  "/ 6 valid digits
 
     "
-     DefaultPrintFormat := '.9' 
-     DefaultPrintFormat := '.6' 
+     DefaultPrintFormat := '.9'. 
+     Float pi printString.     
+
+     DefaultPrintFormat := '.6'. 
+     Float pi printString.     
     "
 ! !
 
@@ -439,7 +442,7 @@
      Do not use (yet) - for now, this is only defined for a
      few selected architectures."
 
-%{
+%{  /* NOCONTEXT */
 #if defined(LINUX) && defined(i386)
 # ifdef NAN
     RETURN (__MKFLOAT(NAN));
@@ -448,7 +451,7 @@
 # endif
 #endif
 %}.
-    ^ 0.0 uncheckedDivide:0.0
+    ^ super NaN
 
     "
      Float NaN    
@@ -458,10 +461,13 @@
     "
 !
 
-infinity
-    "return a float representing infinity"
-
-    ^ 1.0 uncheckedDivide:0.0
+e
+    "return the constant e as Float"
+
+    "/ dont expect this many valid digits on all machines;
+    "/ The actual precision is very CPU specific.
+
+    ^ 2.7182818284590452353602874713526625
 !
 
 pi
@@ -1814,7 +1820,7 @@
 !Float methodsFor:'trigonometric'!
 
 arcCos
-    "return the arccosine of myself (I am interpreted as radians).
+    "return the arccosine of the receiver (as radians).
      Raises an exception, if the receiver is not in -1..1"
 
 %{  /* NOCONTEXT */
@@ -1857,8 +1863,7 @@
 !
 
 arcCosh
-    "return the hyperbolic arccosine of myself (I am interpreted as radians).
-     Raises an exception, if the receiver is not in -1..1"
+    "return the hyperbolic arccosine of the receiver."
 
 %{  /* NOCONTEXT */
 
@@ -1868,7 +1873,7 @@
     val = __floatVal(self);
 
 #ifdef WIN32 /* dont know (yet) how to suppress the warnBox opened by win32 */
-    if ((val >= -1.0) && (val <= 1.0))
+    if (val >= 1.0)
 #endif
     {
         __threadErrno = 0;
@@ -1943,8 +1948,7 @@
 !
 
 arcSinh
-    "return the hyperbolic arcsine of myself (I am interpreted as radians).
-     Raises an exception, if the receiver is not in -1..1"
+    "return the hyperbolic arcsine of the receiver."
 
 %{  /* NOCONTEXT */
 
@@ -1954,7 +1958,7 @@
     val = __floatVal(self);
 
 #ifdef WIN32 /* dont know (yet) how to suppress the warnBox opened by win32 */
-    if ((val >= -1.0) && (val <= 1.0))
+    if (val >= 1.0)
 #endif
     {
         __threadErrno = 0;
@@ -1984,7 +1988,7 @@
 !
 
 arcTan
-    "return the arctangent of myself as radians"
+    "return the arctangent of the receiver (as radians)"
 
 %{  /* NOCONTEXT */
 
@@ -2012,21 +2016,27 @@
 !
 
 arcTanh
-    "return the hyperbolic arctangent of myself as radians"
+    "return the hyperbolic arctangent of the receiver."
 
 %{  /* NOCONTEXT */
 
-    double rslt;
+    double val, rslt;
     OBJ newFloat;
 
     __threadErrno = 0;
-    rslt = atanh(__floatVal(self));
+    val = __floatVal(self);
+# ifdef WIN32 /* dont know (yet) how to suppress the warnBox opened by win32 */
+    if ((val >= -1.0) && (val <= 1.0))
+# endif
+    {
+        rslt = atanh(__floatVal(self));
 #ifdef LINUX /* and maybe others */
-    if (! isnan(rslt))
+        if (! isnan(rslt))
 #endif
-    if (__threadErrno == 0) {
-        __qMKFLOAT(newFloat, rslt);
-        RETURN ( newFloat );
+        if (__threadErrno == 0) {
+            __qMKFLOAT(newFloat, rslt);
+            RETURN ( newFloat );
+        }
     }
 %}.
     ^ self class
@@ -2038,7 +2048,7 @@
 !
 
 cos
-    "return the cosine of myself interpreted as radians"
+    "return the cosine of the receiver (interpreted as radians)"
 
 %{  /* NOCONTEXT */
 
@@ -2066,7 +2076,7 @@
 !
 
 cosh
-    "return the hyperbolic cosine of myself interpreted as radians"
+    "return the hyperbolic cosine of the receiver"
 
 %{  /* NOCONTEXT */
 
@@ -2092,7 +2102,7 @@
 !
 
 sin
-    "return the sine of myself interpreted as radians"
+    "return the sine of the receiver (interpreted as radians)"
 
 %{  /* NOCONTEXT */
 
@@ -2120,7 +2130,7 @@
 !
 
 sinh
-    "return the hyperbolic sine of myself interpreted as radians"
+    "return the hyperbolic sine of the receiver"
 
 %{  /* NOCONTEXT */
 
@@ -2146,7 +2156,7 @@
 !
 
 tan
-    "return the tangent of myself interpreted as radians"
+    "return the tangens of the receiver (interpreted as radians)"
 
 %{  /* NOCONTEXT */
 
@@ -2174,7 +2184,7 @@
 !
 
 tanh
-    "return the hyperbolic tangens of myself interpreted as radians"
+    "return the hyperbolic tangens of the receiver"
 
 %{  /* NOCONTEXT */
 
@@ -2463,7 +2473,7 @@
 !Float class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Float.st,v 1.137 2003-06-17 09:11:52 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Float.st,v 1.138 2003-06-17 11:51:30 cg Exp $'
 ! !
 
 Float initialize!