Commit 737c9641 authored by Stefan Behnel's avatar Stefan Behnel

fix ticket #525: let float values pass through the compiler literally

parent c0e9631f
......@@ -839,12 +839,14 @@ class FloatNode(ConstNode):
return float(self.value)
def calculate_result_code(self):
strval = repr(float(self.value))
if strval == 'nan':
strval = self.value
assert isinstance(strval, (str, unicode))
cmpval = repr(float(strval))
if cmpval == 'nan':
return "(Py_HUGE_VAL * 0)"
elif strval == 'inf':
elif cmpval == 'inf':
return "Py_HUGE_VAL"
elif strval == '-inf':
elif cmpval == '-inf':
return "(-Py_HUGE_VAL)"
else:
return strval
......
DEF FLOAT = 12.5
DEF EFLOAT = 5e-1
DEF FLOAT_NAN = float('nan')
DEF FLOAT_INFP = float('+inf')
DEF FLOAT_INFN = float('-inf')
......@@ -20,6 +21,14 @@ def f():
f = FLOAT
return f
def efloat():
"""
>>> efloat()
0.5
"""
cdef float f = EFLOAT
return f
def nan1():
"""
>>> nan1()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment