Why am I getting a positive result with fractional powers?
The following output from IDLE doesn't make any sense to me.
>>> a=-1.0
>>> a**(1/3)
1.0
>>> a==-1.0
True
>>> -1.0**(1/3)
-1.0
Why do two theoretically equivalent operators return different results? How does Python (2.7) handle the method __pow__
to double, what is the result? I just tried it with integers and got the same result. Apart from calculating the sign of the function entry __pow__
and copying it to the result, how can I fix this?
+3
source to share