Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
cfa644cc
Commit
cfa644cc
authored
Nov 25, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix caching of e+nnn format floats
parent
2601dc12
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
25 deletions
+52
-25
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+1
-1
tests/run/specialfloat.pyx
tests/run/specialfloat.pyx
+51
-24
No files found.
Cython/Compiler/Code.py
View file @
cfa644cc
...
...
@@ -1119,7 +1119,7 @@ class GlobalState(object):
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=''):
...
...
tests/run/specialfloat.pyx
View file @
cfa644cc
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'
)
...
...
@@ -17,16 +18,33 @@ def f():
>>> f()
12.5
"""
cdef
float
f
f
=
FLOAT
cdef
float
f
=
FLOAT
cdef
object
o
=
FLOAT
assert
f
==
o
return
f
def
efloat
():
def
e
m
float
():
"""
>>> efloat()
>>> e
m
float()
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
():
...
...
@@ -34,8 +52,9 @@ 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
():
...
...
@@ -43,8 +62,9 @@ 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
():
...
...
@@ -54,8 +74,9 @@ 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
():
...
...
@@ -65,8 +86,9 @@ 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
():
...
...
@@ -76,8 +98,9 @@ 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
():
...
...
@@ -91,8 +114,9 @@ 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
():
...
...
@@ -102,8 +126,9 @@ 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
():
...
...
@@ -113,8 +138,9 @@ 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
():
...
...
@@ -128,8 +154,9 @@ 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
():
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment