Rounding Bug in Python 2.0! - ugh

Pete Forman gsez020 at kryten.bedford.waii.com
Wed Nov 1 09:39:05 EST 2000


"Tim Peters" <tim_one at email.msn.com> writes:
> As Thomas said, nothing changed here except the precision to which the
> interactive prompt *displays* floats.  Note also:
> 
> >>> 3.123
> 3.1230000000000002
> >>> 3.9
> 3.8999999999999999
> >>>
> 
> That is, these numbers aren't exactly representable in binary
> floating-point, and never were, and "round" has nothing to do with
> it (well, not with *these* examples; the builtin "round" is sloppier
> than it should be, but these examples don't show that).

It would be nice if Python would make use of dtoa() rather than stock
sprintf() to display floating-point numbers.  There are variants of
dtoa in netlib and libg++.
-- 
Pete Forman                 -./\.- Disclaimer: This post is originated
Western Geophysical           -./\.-  by myself and does not represent
pete.forman at westgeo.com         -./\.-  the opinion of Baker Hughes or
http://www.crosswinds.net/~petef  -./\.-  its divisions.



More information about the Python-list mailing list