[pypy-svn] r77322 - pypy/branch/fast-forward/pypy/rlib/rstruct

afa at codespeak.net afa at codespeak.net
Fri Sep 24 08:32:58 CEST 2010


Author: afa
Date: Fri Sep 24 08:32:55 2010
New Revision: 77322

Modified:
   pypy/branch/fast-forward/pypy/rlib/rstruct/ieee.py
Log:
Fix same previous test on 32bit platform.
Should fix pypy-c crashes


Modified: pypy/branch/fast-forward/pypy/rlib/rstruct/ieee.py
==============================================================================
--- pypy/branch/fast-forward/pypy/rlib/rstruct/ieee.py	(original)
+++ pypy/branch/fast-forward/pypy/rlib/rstruct/ieee.py	Fri Sep 24 08:32:55 2010
@@ -54,7 +54,7 @@
     one = r_ulonglong(1)
     sign = rarithmetic.intmask(Q >> BITS - 1)
     exp = rarithmetic.intmask((Q & ((one << BITS - 1) - (one << MANT_DIG - 1))) >> MANT_DIG - 1)
-    mant = Q & ((1 << MANT_DIG - 1) - 1)
+    mant = Q & ((one << MANT_DIG - 1) - 1)
 
     if exp == MAX_EXP - MIN_EXP + 2:
         # nan or infinity
@@ -64,7 +64,7 @@
         result = math.ldexp(mant, MIN_EXP - MANT_DIG)
     else:
         # normal
-        mant += 1 << MANT_DIG - 1
+        mant += one << MANT_DIG - 1
         result = math.ldexp(mant, exp + MIN_EXP - MANT_DIG - 1)
     return -result if sign else result
 
@@ -128,6 +128,8 @@
         assert 0 <= mant < 1 << MANT_DIG - 1
         assert 0 <= exp <= MAX_EXP - MIN_EXP + 2
         assert 0 <= sign <= 1
+
+    exp = r_ulonglong(exp)
     return ((sign << BITS - 1) | (exp << MANT_DIG - 1)) | mant
 
 



More information about the Pypy-commit mailing list