Strange rounding problem

Irmen de Jong irmen at -NOSPAM-REMOVE-THIS-xs4all.nl
Fri Mar 14 18:44:42 EST 2003


Marc wrote:

> This appears to be confusing. The variable is set to .00000096 but is
> passed through as 9.5999999999999991e-007. It appears accurate when
> printed before the value is returned, is inaccurate when the full
> return list is printed, accurate when it's printed by itself after the
> return, and then inaccurate again when the division is made. Why does
> it do this, and how can I avoid it?

You can't avoid it. It's a property of floating point numbers,
not of Python. More info in the FAQ; 
http://www.python.org/cgi-bin/faqw.py?req=show&file=faq04.098.htp

--Irmen





More information about the Python-list mailing list