round function error???

Mark Dickinson dickinsm at gmail.com
Sat Jul 19 00:05:46 CEST 2008


On Jul 18, 10:17 pm, Anthony <ajdam... at gmail.com> wrote:
> Isn't this a mistake???

Which 'this'?  That is, what were you expecting?

If you're objecting to the fact that the second result
produces 3499.3499999999999 instead of 3499.35, then
no, that's not a mistake;  see

http://www.python.org/doc/faq/general/#why-are-floating-point-calculations-so-inaccurate

for more information.  But I'm guessing that you're
questioning the fact that a value that's apparently
*less* than 3499.35 is rounded up to 3499.4, rather
than down to 3499.3.  ?

Then yes, I'd agree that's less than ideal, though I
don't consider it a particularly serious bug.
It's been on my list of things to fix for a while.
(See http://bugs.python.org/issue1869 ).
Contributions welcome!

Mark



More information about the Python-list mailing list