summaryrefslogtreecommitdiff
path: root/libraries/base/cbits
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2011-07-31 20:41:25 +0100
committerIan Lynagh <igloo@earth.li>2011-07-31 20:43:49 +0100
commitb2cec8671df8b6393a4c5a35a35b9893de200ca7 (patch)
treed9e165496bf6b03bb09ae01c0c2ebce013bfc1e4 /libraries/base/cbits
parent95f3b1a41af436648df5eb92e352e17fecb70cf2 (diff)
downloadhaskell-b2cec8671df8b6393a4c5a35a35b9893de200ca7.tar.gz
Fix the behaviour of scaleFloat; part of #3898
Patch from Daniel Fischer.
Diffstat (limited to 'libraries/base/cbits')
-rw-r--r--libraries/base/cbits/primFloat.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/libraries/base/cbits/primFloat.c b/libraries/base/cbits/primFloat.c
index a8f4803772..0e9f9b337f 100644
--- a/libraries/base/cbits/primFloat.c
+++ b/libraries/base/cbits/primFloat.c
@@ -112,6 +112,16 @@ union stg_ieee754_dbl
#ifdef IEEE_FLOATING_POINT
HsInt
+isDoubleFinite(HsDouble d)
+{
+ union stg_ieee754_dbl u;
+
+ u.d = d;
+
+ return u.ieee.exponent != 2047;
+}
+
+HsInt
isDoubleNaN(HsDouble d)
{
union stg_ieee754_dbl u;
@@ -190,6 +200,14 @@ isDoubleNegativeZero(HsDouble d)
HsInt
+isFloatFinite(HsFloat f)
+{
+ union stg_ieee754_flt u;
+ u.f = f;
+ return u.ieee.exponent != 255;
+}
+
+HsInt
isFloatNaN(HsFloat f)
{
union stg_ieee754_flt u;
@@ -426,11 +444,13 @@ rintDouble(HsDouble d)
#else /* ! IEEE_FLOATING_POINT */
-/* Dummy definitions of predicates - they all return false */
+/* Dummy definitions of predicates - they all return "normal" values */
+HsInt isDoubleFinite(d) HsDouble d; { return 1;}
HsInt isDoubleNaN(d) HsDouble d; { return 0; }
HsInt isDoubleInfinite(d) HsDouble d; { return 0; }
HsInt isDoubleDenormalized(d) HsDouble d; { return 0; }
HsInt isDoubleNegativeZero(d) HsDouble d; { return 0; }
+HsInt isFloatFinite(f) HsFloat f; { return 1; }
HsInt isFloatNaN(f) HsFloat f; { return 0; }
HsInt isFloatInfinite(f) HsFloat f; { return 0; }
HsInt isFloatDenormalized(f) HsFloat f; { return 0; }