pow

Why pow(-1, 0) returns 1 instead of -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

Solution

  • It's a precedence thing. Google thinks (-1)0 = 1, as does Python:

    >>> (-1)**0
    1
    

    Any nonzero number raised by the exponent 0 is 1.