Float.st
branchjv
changeset 19572 90f8a4a7060a
parent 19406 faccbadf3034
parent 19570 017c53457288
child 19635 875eb54afd2c
--- a/Float.st	Mon Apr 11 06:38:58 2016 +0200
+++ b/Float.st	Wed Apr 13 09:20:17 2016 +0100
@@ -413,15 +413,15 @@
 %{  /* NOCONTEXT */
 #ifdef __SCHTEAM__
     if (anInteger.isSmallInteger()) {
-        return __c__._RETURN( STDouble._new( (double)(anInteger.longValue()) ));
+	return __c__._RETURN( STDouble._new( (double)(anInteger.longValue()) ));
     }
 #else
     OBJ newFloat;
 
     if (__isSmallInteger(anInteger)) {
-        double f = (double)__smallIntegerVal(anInteger);
-        __qMKFLOAT(newFloat, f);   /* OBJECT ALLOCATION */
-        RETURN (newFloat);
+	double f = (double)__smallIntegerVal(anInteger);
+	__qMKFLOAT(newFloat, f);   /* OBJECT ALLOCATION */
+	RETURN (newFloat);
     }
 #endif /* not SCHTEAM */
 %}.
@@ -430,7 +430,7 @@
     "
      Float fromInteger:123
      Float fromInteger:(100 factorial)
-     (100 factorial) asFloat 
+     (100 factorial) asFloat
     "
 !
 
@@ -490,6 +490,9 @@
 !
 
 epsilon
+    Epsilon isNil ifTrue:[
+	Epsilon := self computeEpsilon.
+    ].
     ^ Epsilon
 ! !
 
@@ -602,18 +605,17 @@
 
 initialize
     Pi isNil ifTrue:[
-        DefaultPrintFormat := '.15'.  "/ print 15 valid digits
-        Pi := 3.14159265358979323846264338327950288419716939937510582097494459.
-        Halfpi := Pi / 2.0.
-        HalfpiNegative := Halfpi negated.
-        Twopi := Pi * 2.0.
-        E := 2.7182818284590452353602874713526625.
-        Sqrt2 := 1.41421356237309504880168872420969808.
-        RadiansPerDegree := Pi / 180.0.
-        Ln2 := 0.69314718055994530941723212145817657.
-        Ln10 := 10.0 ln.
-        Epsilon := self computeEpsilon.
-        MaxSmallInteger := super maxSmallInteger.
+	DefaultPrintFormat := '.15'.  "/ print 15 valid digits
+	Pi := 3.14159265358979323846264338327950288419716939937510582097494459.
+	Halfpi := Pi / 2.0.
+	HalfpiNegative := Halfpi negated.
+	Twopi := Pi * 2.0.
+	E := 2.7182818284590452353602874713526625.
+	Sqrt2 := 1.41421356237309504880168872420969808.
+	RadiansPerDegree := Pi / 180.0.
+	Ln2 := 0.69314718055994530941723212145817657.
+	Ln10 := 10.0 ln.
+	MaxSmallInteger := super maxSmallInteger.
     ].
 
     "
@@ -1148,20 +1150,20 @@
     double result, val;
 
     if (__isSmallInteger(aNumber)) {
-        result = __floatVal(self) / ( (double)__intVal(aNumber)) ;
+	result = __floatVal(self) / ( (double)__intVal(aNumber)) ;
 retResult:
-        __qMKFLOAT(newFloat, result);
-        RETURN ( newFloat );
+	__qMKFLOAT(newFloat, result);
+	RETURN ( newFloat );
     }
     if (__isFloatLike(aNumber)) {
-        val = __floatVal(aNumber);
-        result = __floatVal(self) / val;
-        goto retResult;
+	val = __floatVal(aNumber);
+	result = __floatVal(self) / val;
+	goto retResult;
     }
     if (__isShortFloat(aNumber)) {
-        val = (double)(__shortFloatVal(aNumber));
-        result = __floatVal(self) / val;
-        goto retResult;
+	val = (double)(__shortFloatVal(aNumber));
+	result = __floatVal(self) / val;
+	goto retResult;
     }
 %}.
     ^ aNumber quotientFromFloat:self
@@ -1576,7 +1578,6 @@
     int nEpsilon;
     double scaledEpsilon;
 
-
     if (!__isSmallInteger(nE)) {
 	goto tryHarder;
     }
@@ -1827,34 +1828,34 @@
     OBJ newFloat;
 
     if (__isFloatLike(n)) {
-        __threadErrno = 0;
-        rslt = pow(__floatVal(self), __floatVal(n));
-        if (! isnan(rslt))  /* Currently all our systems support isnan() */
-        {
-            if (__threadErrno == 0) {
-                __qMKFLOAT(newFloat, rslt);
-                RETURN ( newFloat );
-            }
-        }
+	__threadErrno = 0;
+	rslt = pow(__floatVal(self), __floatVal(n));
+	if (! isnan(rslt))  /* Currently all our systems support isnan() */
+	{
+	    if (__threadErrno == 0) {
+		__qMKFLOAT(newFloat, rslt);
+		RETURN ( newFloat );
+	    }
+	}
     }
 %}.
     "/ the c-library pow functin, has a bug:
-    "/ it does not deal correctly with negative numbers. 
+    "/ it does not deal correctly with negative numbers.
     "/ I.e. it raises an error on -8^(1/3) instead of returning a negative -2
     "/ work around with a kludge:
     self < 0 ifTrue:[
-        ^ (self negated raisedTo:n) negated
+	^ (self negated raisedTo:n) negated
     ].
 
     "
      an invalid argument (not convertable to float ?)
     "
     ^ self class
-        raise:#domainErrorSignal
-        receiver:self
-        selector:#raisedTo:
-        arguments:(Array with:aNumber)
-        errorString:'bad receiver/arg in raisedTo:'
+	raise:#domainErrorSignal
+	receiver:self
+	selector:#raisedTo:
+	arguments:(Array with:aNumber)
+	errorString:'bad receiver/arg in raisedTo:'
 
     "Modified: / 16.11.2001 / 14:16:51 / cg"
 !
@@ -2512,12 +2513,12 @@
 %}.
 
     "
-        0.0 positive
-        -0.0 positive
-        1.0 positive
-        -1.0 positive
-        (1.0 uncheckedDivide: 0.0) positive
-        (-1.0 uncheckedDivide: 0.0) positive
+	0.0 positive
+	-0.0 positive
+	1.0 positive
+	-1.0 positive
+	(1.0 uncheckedDivide: 0.0) positive
+	(-1.0 uncheckedDivide: 0.0) positive
     "
 !