Mathematics in Python are not correct

Michael Torrie torriem at gmail.com
Thu May 8 19:11:56 EDT 2008


Ahem...  That should have been:

(negate (pow 123 0))

Using parenthesis to indicate precedence order of ops:

-(123 ^ 0)

The "-" you are using is not part of the number.  It's a unary operator
that negates something.  In normal order of operations, it has a much
lower priority than power.

Your post really took me back to my grade school days!  I remember first
looking with consternation at my scientific calculator when it insisted
that -2^0 is -1.

The order of python operations can be found here:

http://docs.python.org/ref/summary.html

Hope this helps



More information about the Python-list mailing list