* [EMAIL PROTECTED] <[EMAIL PROTECTED]> [2008-05-08 15:54:42 -0700]: > 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. >
And why is this a problem ? It is the "standard" operator precedence that -123^0 is -(123^0), isn't it ? > 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. > That's what it does : >>> -123**0 -1 >>> (-123)**0 1 > This is a rare case when the parser is fooled, but it must be fixed in > order to produce the correct mathematical result. Again, the mathematical result is correct. -123^0 is -(123^0), not (-123)^0. Regards, -- Nicolas Dandrimont
signature.asc
Description: Digital signature
-- http://mail.python.org/mailman/listinfo/python-list