[issue1580] Use shorter float repr when possible

Guido van Rossum report at bugs.python.org
Tue Dec 11 20:03:41 CET 2007


Guido van Rossum added the comment:

> Correct rounding is a property that needs to be proved, not tested.

I take it your position is that this can never be done 100% correctly so
it shouldn't go in?  That's disappointing, because the stream of
complaints that "round is broken" won't stop (we had two of these in the
bug tracker just this month).

I really want to address this without having to either change
interactive mode to use something besides repr() or changing repr() to
drop precision (assuming correctly rounding input).

We can fix the roundtripping in marshal and pickle and the like by
explicitly using "%.17g" % x instead of repr(x).  Scientists who worry
about roundtripping can also do this (though are there any scientists
who work on platforms that don't have correctly-rounding input routines?).

We can also fix it by adopting the Tcl string-to-float code.

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1580>
__________________________________


More information about the Python-bugs-list mailing list