--- a/ShortFloat.st Tue Jun 20 12:22:03 2017 +0200
+++ b/ShortFloat.st Tue Jun 20 12:22:18 2017 +0200
@@ -1679,12 +1679,12 @@
!ShortFloat 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.
This assumes that the mantissa is normalized to
- 0.5 .. 1.0 and the floats value is mantissa * 2^exp"
+ 0.5 .. 1.0 and the float's value is mantissa * 2^exp"
%{ /* NOCONTEXT */
int exp;
@@ -1696,6 +1696,7 @@
#endif
RETURN (__mkSmallInteger(exp));
%}.
+ ^ super exponent
"
4.0 asShortFloat exponent
@@ -1705,6 +1706,8 @@
0.25 asShortFloat exponent
0.00000011111 asShortFloat exponent
"
+
+ "Modified: / 20-06-2017 / 11:33:41 / cg"
!
mantissa
@@ -1716,21 +1719,31 @@
0.5 .. 1.0 and the floats value is mantissa * 2^exp"
%{ /* NOCONTEXT */
+ float myVal;
int exp;
+ myVal = __shortFloatVal(self);
+ // ouch: math libs seem to not care for NaN here;
+#if 1
+ // should we?
+ if (!isnanf(myVal) && isfinitef(myVal))
+#endif
+ {
#if defined(__i386__) && defined(__GNUC__)
- float frac = frexpf(__shortFloatVal(self), &exp);
- RETURN (__MKSFLOAT(frac));
+ float frac = frexpf(myVal, &exp);
+ RETURN (__MKSFLOAT(frac));
#else
- double frac = frexp( (double)(__shortFloatVal(self)), &exp);
- RETURN (__MKFLOAT(frac));
+ double frac = frexp( (double)(myVal), &exp);
+ RETURN (__MKFLOAT(frac));
#endif
+ }
%}.
^ super mantissa
"
1.0 asShortFloat exponent
1.0 asShortFloat mantissa
+ 1e1000 asShortFloat mantissa
0.5 asShortFloat exponent
0.5 asShortFloat mantissa
@@ -1741,6 +1754,8 @@
0.00000011111 asShortFloat exponent
0.00000011111 asShortFloat mantissa
"
+
+ "Modified: / 20-06-2017 / 11:41:11 / cg"
! !
!ShortFloat methodsFor:'testing'!