Rounding error in Python 2.0

Fredrik Lundh fredrik at effbot.org
Tue Dec 5 23:36:48 EST 2000


sragsdale at my-deja.com write:
> Can anyone explain to me why python2 can't read a float from a string?
> Python 1.5.2 didn't have this problem.

it sure had the same problem.  it just didn't tell you.

    http://www.python.org/cgi-bin/moinmoin/FrequentlyAskedQuestions

    Q. Floating point is broken!

    A. Binary floating point cannot represent decimal fractions
    exactly, so some rounding always occurs (even in Python
    1.5.2).

    What changed is that Python 2.0 shows more precision than
    before in certain circumstances (repr() and the interactive
    prompt).

for more info, see:

    http://www.python.org/cgi-bin/moinmoin/RepresentationError

</F>






More information about the Python-list mailing list