--- a/Float.st Tue Jun 20 12:19:25 2017 +0200
+++ b/Float.st Tue Jun 20 12:22:03 2017 +0200
@@ -754,13 +754,14 @@
%}
"
- self getFPUControl
+ self getFPUControl
"
+
+ "Modified (comment): / 20-06-2017 / 11:51:58 / cg"
!
setFPUControl
- "set the fpu control word.
- We want 64 bit precision for long double here"
+ "BORLAND only: set the fpu control word for 64 bit precision for long doubles here"
%{
#ifdef __BORLANDC__
@@ -773,8 +774,10 @@
%}
"
- self setFPUControl
+ self setFPUControl
"
+
+ "Modified (comment): / 20-06-2017 / 11:51:54 / cg"
! !
!Float class methodsFor:'queries'!
@@ -2327,7 +2330,7 @@
!Float methodsFor:'special access'!
exponent
- "extract a normalized floats exponent.
+ "extract a normalized float's exponent.
The returned value depends on the float-representation of
the underlying machine and is therefore highly unportable.
This is not for general use.
@@ -2335,13 +2338,22 @@
0.5 .. 1.0 and the float's value is: mantissa * 2^exp"
%{ /* NOCONTEXT */
-
+ double myVal;
double frac;
int exp;
- frac = frexp(__floatVal(self), &exp);
- RETURN (__mkSmallInteger(exp));
+ myVal = __floatVal(self);
+ // ouch: math libs seem to not care for NaN here;
+#if 1
+ // should we?
+ if (! (isnan(myVal) || isinf(myVal)))
+#endif
+ {
+ frac = frexp(myVal, &exp);
+ RETURN (__mkSmallInteger(exp));
+ }
%}.
+ ^ super exponent
"
1.0 exponent
@@ -2353,7 +2365,11 @@
0.25 exponent
0.2 exponent
0.00000011111 exponent
+ 0.0 exponent
+ 1e1000 exponent
"
+
+ "Modified: / 20-06-2017 / 11:34:43 / cg"
!
mantissa
@@ -2365,12 +2381,20 @@
0.5 .. 1.0 and the floats value is mantissa * 2^exp"
%{ /* NOCONTEXT */
-
+ double myVal;
double frac;
int exp;
- frac = frexp(__floatVal(self), &exp);
- RETURN (__MKFLOAT(frac));
+ myVal = __floatVal(self);
+ // ouch: math libs seem to not care for NaN here;
+#if 1
+ // should we?
+ if (! (isnan(myVal) || isinf(myVal)))
+#endif
+ {
+ frac = frexp(myVal, &exp);
+ RETURN (__MKFLOAT(frac));
+ }
%}.
^ super mantissa
@@ -2383,7 +2407,11 @@
0.00000011111 exponent
0.00000011111 mantissa
+
+ 1e1000 mantissa
"
+
+ "Modified: / 20-06-2017 / 11:37:13 / cg"
! !
!Float methodsFor:'testing'!