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
c1fe135f
Commit
c1fe135f
authored
Oct 27, 2018
by
Kryštof Pilnáček
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix: Exponentiation of integer constants
parent
336d8ca7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
0 deletions
+17
-0
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+6
-0
tests/run/constant_folding.py
tests/run/constant_folding.py
+11
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
c1fe135f
...
...
@@ -11745,6 +11745,12 @@ class PowNode(NumBinopNode):
error
(
self
.
pos
,
"got unexpected types for C power operator: %s, %s"
%
(
self
.
operand1
.
type
,
self
.
operand2
.
type
))
def
compute_c_result_type
(
self
,
type1
,
type2
):
c_result_type
=
super
(
PowNode
,
self
).
compute_c_result_type
(
type1
,
type2
)
if
isinstance
(
self
.
operand2
.
constant_result
,
_py_int_types
)
and
self
.
operand2
.
constant_result
<
0
:
c_result_type
=
PyrexTypes
.
widest_numeric_type
(
c_result_type
,
PyrexTypes
.
c_double_type
)
return
c_result_type
def
calculate_result_code
(
self
):
# Work around MSVC overloading ambiguity.
def
typecast
(
operand
):
...
...
tests/run/constant_folding.py
View file @
c1fe135f
...
...
@@ -136,6 +136,17 @@ def binop_mul_pow():
return
(
mul_int
,
mul_large_int
,
pow_int
,
pow_large_int
)
def
binop_pow_negative
():
"""
>>> print_big_ints(binop_pow_negative())
(4.018775720164609e-06, 8.020807320287816e-38, 0.1)
"""
pow_int
=
12
**
-
5
pow_large_int
=
1234
**
-
12
pow_expression_int
=
10
**
(
1
-
2
)
return
(
pow_int
,
pow_large_int
,
pow_expression_int
)
@
cython
.
test_fail_if_path_exists
(
"//SliceIndexNode"
,
)
...
...
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