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

benjamin at codespeak.net benjamin at codespeak.net
Tue Sep 14 23:54:28 CEST 2010

```Author: benjamin
Date: Tue Sep 14 23:54:26 2010
New Revision: 77074

Modified:
pypy/branch/fast-forward/pypy/rlib/rstruct/ieee.py
Log:
mant should always be a float

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	Tue Sep 14 23:54:26 2010
@@ -50,18 +50,18 @@
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 & ((one << MANT_DIG - 1) - 1)
+    mant = Q & ((1 << MANT_DIG - 1) - 1)

if exp == MAX_EXP - MIN_EXP + 2:
# nan or infinity
result = float('nan') if mant else float('inf')
elif exp == 0:
# subnormal or zero
-        result = math.ldexp(float(mant), MIN_EXP - MANT_DIG)
+        result = math.ldexp(mant, MIN_EXP - MANT_DIG)
else:
# normal
-        mant += r_ulonglong(1) << MANT_DIG - 1
-        result = math.ldexp(float(mant), exp + MIN_EXP - MANT_DIG - 1)
+        mant += 1 << MANT_DIG - 1
+        result = math.ldexp(mant, exp + MIN_EXP - MANT_DIG - 1)
return -result if sign else result

```

More information about the Pypy-commit mailing list