On Jul 19, 8:05 am, Mark Dickinson <[EMAIL PROTECTED]> wrote: > On Jul 18, 10:17 pm, Anthony <[EMAIL PROTECTED]> 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-calcula... > > 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. ?
"apparently" being the operative word. >>> x = 3499.35 >>> repr(x) '3499.3499999999999' >>> float(repr(x)) == x True >>> float(repr(x)) < x False > > 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. I'd suggest adding this to the list of floating point strangenesses in the FAQ and/or the appendix to the tutorial, rather than "fixing" it. > (See http://bugs.python.org/issue1869). The example you give there seems to be somewhat more deserving of a fix. Cheers, John -- http://mail.python.org/mailman/listinfo/python-list