Tim Peters added the comment: There is nothing you can do to repr() that's sufficient by itself to ensure eval(repr(x)) == x.
The other necessary part is correctly rounded float /input/ routines. The 754 standard does not require correctly rounding input or output routines. It does require that eval(repr(x)) == x provided that repr(x) produce at least 17 significant digits (not necessarily correctly rounded, but "good enough" so that eval(repr(x)) == x). That's why Python produces 17 significant digits. While there's no guarantee that all platform I/O routines are good enough to meet the 754 requirement, most do, and what Python's repr() actually does is the strongest that /can/ be done assuming no more than full 754 conformance. Again, this cannot be improved cross-platform without Python supplying both output and input routines. Burger's output routines supply only half of what's needed. An efficient way to do the other half (correctly rounding input) was first written up by Clinger. Note that neither the Burger/Dybvig output code nor the Clinger input code are used much in practice anymore; David Gay's code is usually used instead for "go fast" reasons: http://mail.python.org/pipermail/python-list/2004-July/272167.html Clinger also endorses Gay's code: ftp://ftp.ccs.neu.edu/pub/people/will/retrospective.pdf However, as the Python list link says, Gay's code is "mind-numbingly complicated". There is no easy cross-platform solution, where "cross-platform" means just "limited to 754 platforms". __________________________________ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue1580> __________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com