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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
737c9641
Commit
737c9641
authored
May 11, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix ticket #525: let float values pass through the compiler literally
parent
c0e9631f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
4 deletions
+15
-4
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+6
-4
tests/run/specialfloat.pyx
tests/run/specialfloat.pyx
+9
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
737c9641
...
@@ -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
str
val
==
'inf'
:
elif
cmp
val
==
'inf'
:
return
"Py_HUGE_VAL"
return
"Py_HUGE_VAL"
elif
str
val
==
'-inf'
:
elif
cmp
val
==
'-inf'
:
return
"(-Py_HUGE_VAL)"
return
"(-Py_HUGE_VAL)"
else
:
else
:
return
strval
return
strval
...
...
tests/run/specialfloat.pyx
View file @
737c9641
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()
...
...
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