As google suggests -10=-1. And as I understand pow() function in javascript, python and C should return the same result. But it's not true. Why?
Python:
>>> pow(-1, 0)
1
As google suggests -10=-1. And as I understand pow() function in javascript, python and C should return the same result. But it's not true. Why?
Python:
>>> pow(-1, 0)
1
It's a precedence thing. Google thinks (-1)0 = 1, as does Python:
>>> (-1)**0
1
You forgot the parenthesis!
-1 ^ 0 = -(1 ^ 0) = -(1) = -1
because power operator has higher precedence.
But:
(-1)^0 = 1
(-10) is the same as saying (-1/-1) which is 1.
In division you substract the exponent of the denominator from the exponent of the numerator. For this rule to hold true all number elevated to the power of zero is 1. 51 / 51 = 50 = 1