[Python-3000] Reconsider repr(0.1) == '0.10000000000000001'
Marcin ‘Qrczak’ Kowalczyk
qrczak at knm.org.pl
Sun Dec 9 12:09:23 CET 2007
Dnia 09-12-2007, N o godzinie 10:33 +0200, Noam Raphael pisze:
> I think that the reason for the long representation is that it uses a
> simple algorithm that makes "eval(repr(f)) == f" always true. However,
> why not use another, a bit more complex, algorithm, which will still
> preserve "eval(repr(f)) == f", but which will shorten the result when
> it can?
"Printing Floating-Point Numbers Quickly and Accurately"
Robert G. Burger, R. Kent Dybvig
http://www.cs.indiana.edu/~burger/FP-Printing-PLDI96.pdf
http://www.cs.indiana.edu/~burger/
I used this algorithm for my language Kogut.
--
__("< Marcin Kowalczyk
\__/ qrczak at knm.org.pl
^^ http://qrnik.knm.org.pl/~qrczak/
More information about the Python-3000
mailing list