Commit c1fe135f authored by Kryštof Pilnáček's avatar Kryštof Pilnáček

Fix: Exponentiation of integer constants

parent 336d8ca7
......@@ -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):
......
......@@ -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",
)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment