!!! 2.1, 2.2, 2.2.1, PYTHON BUGS ????

Delaney, Timothy tdelaney at avaya.com
Thu May 30 20:49:34 EDT 2002


> From: David K. Trudgett [mailto:dkt at registriesltd.com.au]
> 
> On Friday 2002-05-31 at 10:18:34 +1000, Delaney, Timothy wrote:
> 
> In one way, I don't mind getting "correct" answers, but in another
> way, with my RAD hat on, I'd prefer not to have to worry too much
> about rounding errors and such. I don't know how Perl and Python 1.5.2
> manage their trickery, but I suppose it could raise its ugly head and
> bite you one day. :-)

http://www.python.org/doc/2.2.1/tut/node14.html

All you are seeing is the string representation repr(). In 1.5.2, repr()
gave the same result as str() - two places of decimal precision. In 2.0+ it
does the "right" thing. str() still gives two places of decimal precision.

If you want to display a certain precision, you need to do it yourself.
round() will not change things ...

print repr(round(0.10000000000000001, 1))

Tim Delaney





More information about the Python-list mailing list