Re: Mathematics in Python are not correct

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ben Finney

    Re: Mathematics in Python are not correct

    wxPythoner@gmai l.com writes:
    The problem is that Python parses -123**0 as -(123**0), not as
    (-123)**0.
    As explicitly defined in the language reference, the "negative"
    operator has lower binding precedence than the "power" operator
    <URL:http://www.python.org/doc/ref/summary.html>.
    I suggest making the Python parser omit the negative sign if a
    negative number is raised to the power of 0.
    It does, if you actually have a negative number that you're raising to
    power 0.
    >>(-123)**0
    1
    This is a rare case when the parser is fooled
    The parser is operating according to the documented language
    specification. It can't account for the user being fooled by external
    sources.

    --
    \ "You know what I hate? Indian givers... no, I take that back." |
    `\ -- Emo Philips |
    _o__) |
    Ben Finney
Working...