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): ...@@ -839,12 +839,14 @@ class FloatNode(ConstNode):
return float(self.value) return float(self.value)
def calculate_result_code(self): def calculate_result_code(self):
strval = repr(float(self.value)) strval = self.value
if strval == 'nan': assert isinstance(strval, (str, unicode))
cmpval = repr(float(strval))
if cmpval == 'nan':
return "(Py_HUGE_VAL * 0)" return "(Py_HUGE_VAL * 0)"
elif strval == 'inf': elif cmpval == 'inf':
return "Py_HUGE_VAL" return "Py_HUGE_VAL"
elif strval == '-inf': elif cmpval == '-inf':
return "(-Py_HUGE_VAL)" return "(-Py_HUGE_VAL)"
else: else:
return strval return strval
......
DEF FLOAT = 12.5 DEF FLOAT = 12.5
DEF EFLOAT = 5e-1
DEF FLOAT_NAN = float('nan') DEF FLOAT_NAN = float('nan')
DEF FLOAT_INFP = float('+inf') DEF FLOAT_INFP = float('+inf')
DEF FLOAT_INFN = float('-inf') DEF FLOAT_INFN = float('-inf')
...@@ -20,6 +21,14 @@ def f(): ...@@ -20,6 +21,14 @@ def f():
f = FLOAT f = FLOAT
return f return f
def efloat():
"""
>>> efloat()
0.5
"""
cdef float f = EFLOAT
return f
def nan1(): def nan1():
""" """
>>> 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