elif py_type == 'float':
prefix = Naming.interned_float_prefix
cname = "%s%s" % (prefix, value)
- cname = cname.replace('-', 'neg_').replace('.', '_')
+ cname = cname.replace('+', '_').replace('-', 'neg_').replace('.', '_')
return cname
def new_const_cname(self, prefix='', value=''):
DEF FLOAT = 12.5
-DEF EFLOAT = 5e-1
+DEF EMFLOAT = 5e-1
+DEF EPFLOAT = 5e+1
DEF FLOAT_NAN = float('nan')
DEF FLOAT_INFP = float('+inf')
DEF FLOAT_INFN = float('-inf')
>>> f()
12.5
"""
- cdef float f
- f = FLOAT
+ cdef float f = FLOAT
+ cdef object o = FLOAT
+ assert f == o
return f
-def efloat():
+def emfloat():
"""
- >>> efloat()
+ >>> emfloat()
0.5
"""
- cdef float f = EFLOAT
+ cdef float f = EMFLOAT
+ assert f == 5e-1
+ cdef object o = EMFLOAT
+ assert o == 5e-1
+ assert f == o
+ return f
+
+def epfloat():
+ """
+ >>> epfloat()
+ 50.0
+ """
+ cdef float f = EPFLOAT
+ assert f == 5e+1
+ cdef object o = EPFLOAT
+ assert o == 5e+1
+ assert f == o
return f
def nan1():
>>> nan1()
nan
"""
- cdef double f
- f = FLOAT_NAN
+ cdef double f = FLOAT_NAN
+ cdef object o = FLOAT_NAN
+ assert str(f) == str(o)
return f
def nan2():
>>> nan2()
nan
"""
- cdef double f
- f = float('nan')
+ cdef double f = float('nan')
+ cdef object o = float('nan')
+ assert str(f) == str(o)
return f
def nan3():
>>> float_nan
nan
"""
- cdef float f
- f = FLOAT_NAN
+ cdef float f = FLOAT_NAN
+ cdef object o = FLOAT_NAN
+ assert str(f) == str(o)
return f
def infp1():
>>> infp1() == float('inf')
True
"""
- cdef double f
- f = FLOAT_INFP
+ cdef double f = FLOAT_INFP
+ cdef object o = FLOAT_INFP
+ assert f == o
return f
def infp2():
>>> infp2() == float('inf')
True
"""
- cdef double f
- f = float('+inf')
+ cdef double f = float('+inf')
+ cdef object o = float('+inf')
+ assert f == o
return f
def infp3():
>>> float_infp == float('inf')
True
"""
- cdef float f
- f = FLOAT_INFP
+ cdef float f = FLOAT_INFP
+ cdef object o = FLOAT_INFP
+ assert f == o
return f
def infn1():
>>> infn1() == float('-inf')
True
"""
- cdef double f
- f = FLOAT_INFN
+ cdef double f = FLOAT_INFN
+ cdef object o = FLOAT_INFN
+ assert f == o
return f
def infn2():
>>> infn2() == float('-inf')
True
"""
- cdef double f
- f = float('-inf')
+ cdef double f = float('-inf')
+ cdef object o = float('-inf')
+ assert f == o
return f
def infn3():
>>> float_infn == float('-inf')
True
"""
- cdef float f
- f = FLOAT_INFN
+ cdef float f = FLOAT_INFN
+ cdef object o = FLOAT_INFN
+ assert f == o
return f
def global_floats():