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
Kirill Smelkov
cython
Commits
495011ef
Commit
495011ef
authored
Apr 21, 2008
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix inf/NaN float constants
parent
a60e97c2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
0 deletions
+35
-0
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+11
-0
tests/run/ct_DEF.pyx
tests/run/ct_DEF.pyx
+24
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
495011ef
...
...
@@ -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
):
...
...
tests/run/ct_DEF.pyx
View file @
495011ef
...
...
@@ -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
...
...
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