Author: mattip <[email protected]>
Branch: numpypy-longdouble
Changeset: r59545:6a14d6e6e0c7
Date: 2012-12-14 15:21 +0200
http://bitbucket.org/pypy/pypy/changeset/6a14d6e6e0c7/

Log:    support nan, inf for 80 bit extended doubles

diff --git a/pypy/rlib/rstruct/ieee.py b/pypy/rlib/rstruct/ieee.py
--- a/pypy/rlib/rstruct/ieee.py
+++ b/pypy/rlib/rstruct/ieee.py
@@ -49,10 +49,7 @@
 
     if exp == MAX_EXP - MIN_EXP + 2:
         # nan or infinity
-        result = rfloat.NAN if mant else rfloat.INFINITY
-    elif exp == 0:
-        # subnormal or zero
-        result = math.ldexp(mant, MIN_EXP - MANT_DIG)
+        result = rfloat.NAN if mant &((one << MANT_DIG - 1) - 1) else 
rfloat.INFINITY
     else:
         # normal
         result = math.ldexp(mant, exp + MIN_EXP - MANT_DIG - 1)
diff --git a/pypy/rlib/rstruct/test/test_ieee.py 
b/pypy/rlib/rstruct/test/test_ieee.py
--- a/pypy/rlib/rstruct/test/test_ieee.py
+++ b/pypy/rlib/rstruct/test/test_ieee.py
@@ -65,6 +65,12 @@
         self.check_float(-0.0)
 
     def test_nans(self):
+        Q = float_pack128(float('nan'), 16)
+        y = float_unpack80(Q, 16)
+        assert repr(y) == 'nan'
+        Q = float_pack128(float('nan'), 12)
+        y = float_unpack80(Q, 12)
+        assert repr(y) == 'nan'
         Q = float_pack(float('nan'), 8)
         y = float_unpack(Q, 8)
         assert repr(y) == 'nan'
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to