round function error???
sjmachin at lexicon.net
Sat Jul 19 01:20:44 CEST 2008
On Jul 19, 8:05 am, Mark Dickinson <dicki... at gmail.com> wrote:
> 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
> 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
>>> float(repr(x)) == x
>>> float(repr(x)) < x
> 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
More information about the Python-list