Mathematics in Python are not correct

wxPythoner at gmail.com wxPythoner at gmail.com
Thu May 8 18:54:42 EDT 2008


Have a look at this:

>>> -123**0
-1


The result is not correct, because every number (positive or negative)
raised to the power of 0 is ALWAYS 1 (a positive number 1 that is).

The problem is that Python parses -123**0 as -(123**0), not as
(-123)**0.

I suggest making the Python parser omit the negative sign if a
negative number is raised to the power of 0. That way the result will
always be a positive 1, which is the mathematically correct result.

This is a rare case when the parser is fooled, but it must be fixed in
order to produce the correct mathematical result.



More information about the Python-list mailing list