Commit 495011ef authored by Stefan Behnel's avatar Stefan Behnel

fix inf/NaN float constants

parent a60e97c2
......@@ -677,6 +677,17 @@ class FloatNode(ConstNode):
def compile_time_value(self, denv):
return float(self.value)
def calculate_result_code(self):
strval = str(self.value)
if strval == 'nan':
return "NAN"
elif strval == 'inf':
return "INFINITY"
elif strval == '-inf':
return "(-INFINITY)"
else:
return strval
class StringNode(ConstNode):
......
......@@ -11,6 +11,12 @@ __doc__ = """
666
>>> f()
12.5
>>> nan()
nan
>>> infp()
inf
>>> infn()
-inf
>>> s()
'spam'
>>> two()
......@@ -32,6 +38,9 @@ DEF INT2 = 0x42
DEF INT3 = 042
DEF LONG = 666L
DEF FLOAT = 12.5
DEF FLOAT_NAN = float('nan')
DEF FLOAT_INFP = float('+inf')
DEF FLOAT_INFN = float('-inf')
DEF STR = "spam"
DEF TWO = TUPLE[1]
DEF FIVE = TWO + 3
......@@ -68,6 +77,21 @@ def f():
f = FLOAT
return f
def nan():
cdef float f
f = FLOAT_NAN
return f
def infp():
cdef float f
f = FLOAT_INFP
return f
def infn():
cdef float f
f = FLOAT_INFN
return f
def s():
cdef char *s
s = STR
......
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