floating point glitch

Paul Rubin http
Sun Sep 26 11:24:35 CEST 2004


Michael Hoffman <m.h.3.9.1.without.dots.at.cam.ac.uk at example.com> writes:
> Actually, print essentialy uses str() to get the string
> representation. But repr(list) or str(list) still gets the repr() of
> each item of the list rather than the str():

    >>> print .66
    0.66
    >>> print [.66]
    [0.66000000000000003]

Yucch!  Also, str is not invertible:

    >>> a=.66
    >>> b=a+1e-16
    >>> a==b
    False
    >>> str(a)
    '0.66'
    >>> str(b)
    '0.66'



More information about the Python-list mailing list