[Python-Dev] Expert floats
Andrew Koenig
ark-mlist at att.net
Wed Mar 31 15:00:42 EST 2004
> Binary fp loses in these common cases *just because* the true inputs can't
> be represented, and the number printed at the end isn't even the true
> result of approximately adding the approximated inputs. Decimal easily
> avoids all of that.
Well, some of it. It still doesn't avoid 1E50 + 1E-50 == 1E50, for example.
> > Why are you not arguing against decimal floating-point if your goal
> > is to expose users to the problems of floating-point as early as
> > possible?
> The overwhelmingly most common newbie binary fp traps today are failures
> to realize that the numbers they type aren't the numbers they get, and
> that the numbers they see aren't the results they got.
Then how about giving a warning for every floating-point literal that cannot
be exactly represented in binary?
More information about the Python-Dev
mailing list