[pypy-svn] r16114 - in pypy/dist/pypy/translator/llvm2: . test

rxe at codespeak.net rxe at codespeak.net
Wed Aug 17 17:00:46 CEST 2005


Author: rxe
Date: Wed Aug 17 17:00:44 2005
New Revision: 16114

Modified:
   pypy/dist/pypy/translator/llvm2/database.py
   pypy/dist/pypy/translator/llvm2/test/test_lltype.py
Log:
Fix up floating point number representation issues (thanks mwh)



Modified: pypy/dist/pypy/translator/llvm2/database.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/database.py	(original)
+++ pypy/dist/pypy/translator/llvm2/database.py	Wed Aug 17 17:00:44 2005
@@ -314,7 +314,10 @@
         elif repr in ["inf", "nan"]:
             # Need hex repr
             import struct
-            packed = struct.pack("d", value)                
+            packed = struct.pack("d", value)
+            if sys.byteorder == 'little':
+                packed = packed[::-1]
+            
             repr = "0x" + "".join([("%02x" % ord(ii)) for ii in packed])
         return repr
 

Modified: pypy/dist/pypy/translator/llvm2/test/test_lltype.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/test/test_lltype.py	(original)
+++ pypy/dist/pypy/translator/llvm2/test/test_lltype.py	Wed Aug 17 17:00:44 2005
@@ -227,16 +227,14 @@
     floats.f1 = 1.25
     floats.f2 = 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.252984
     floats.f3 = float(29050000000000000000000000000000000000000000000000000000000000000000)
-    floats.f4 = float("inf")
-    floats.f5 = float("nan")
-    f = float("nan")
+    floats.f4 = 1e300 * 1e300
+    nan = floats.f5 = floats.f4/floats.f4
     def floats_fn():
         res  = floats.f1 == 1.25
         res += floats.f2 > 1e100
-        res += floats.f3 > 1e50
-        # XXX Need to find out more about these in llvm
-        #res += floats.f4 > 1e200
-        #res += floats.f5 == f
+        res += floats.f3 > 1e50        
+        res += floats.f4 > 1e200
+        res += floats.f5 == nan
         return res
     
     f = compile_function(floats_fn, [])



More information about the Pypy-commit mailing list