[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Floating point inaccuracies
- From: Dirk Laurie <dpl@...>
- Date: Mon, 29 Nov 2010 07:15:02 +0200
On Mon, Nov 29, 2010 at 12:41:00AM +0200, Andrew Lentvorski wrote:
> On 11/28/10 1:28 PM, Patrick Rapin wrote:
> > This sort of problems, not directly related to Lua but to the
> > IEEE 754 floating point standard, comes up regularly to the list.
> > Wouldn't be possible to find a more generic solution?
>
> 1) Switch to Decimal Floating Point: http://speleotrove.com/decimal/
>
That solves only the problem of data/text import/export. It will
still seldom be true that expressions that should be equal by the
distributive and associative laws actually test equal.
> 2) Cram Goldberg down the throat of everyone who asks:
> "What Every Computer Scientist Should Know About Floating Point Arithmetic"
> http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.22.6768
>
Now _that_ is a good suggestion.
As you carefully avoided saying, any introductory course on numerical
analysis goes into this topic, and I'm sure Patrick knows that. The
question relevant here is not whether one could define an operator
that cleverly compares floating point numbers, but:
Does it fit into the Lua philosophy to make "==" mean not simply
"equals", but "in exact arithmetic probably would have equalled"?
And to that question the answer is clearly "no".
Dirk