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
5fdbfe49
Commit
5fdbfe49
authored
Oct 27, 2018
by
Stefan Behnel
Committed by
GitHub
Oct 27, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2683 from KPilnacek/2133_exponentiation_of_int
Fix: Exponentiation of integer constants
parents
c2de8efb
768b7489
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
1 deletion
+17
-1
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+6
-0
docs/src/tutorial/caveats.rst
docs/src/tutorial/caveats.rst
+0
-1
tests/run/constant_folding.py
tests/run/constant_folding.py
+11
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
5fdbfe49
...
...
@@ -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
):
...
...
docs/src/tutorial/caveats.rst
View file @
5fdbfe49
...
...
@@ -5,7 +5,6 @@ Since Cython mixes C and Python semantics, some things may be a bit
surprising or unintuitive. Work always goes on to make Cython more natural
for Python users, so this list may change in the future.
- ``10**-2 == 0``, instead of ``0.01`` like in Python.
- Given two typed ``int`` variables ``a`` and ``b``, ``a % b`` has the
same sign as the second argument (following Python semantics) rather than
having the same sign as the first (as in C). The C behavior can be
...
...
tests/run/constant_folding.py
View file @
5fdbfe49
...
...
@@ -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