lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Also against any additional custom floating point logic.

First if you read a book having a chapter about this, it should come
clear that all discussions have already been discussed through in vast
detail and floating point as we have it today is not without the
reason it is the way it is.

So first, if default == would mean any floating point "close to", the
very first thing the next user will ask is that in his/her specific
usecase s/he needs to compare _exactly_, so then you add === to the
language and you down the PHP road with more confusing operators.

Secondly how many digits mean equal depends on your application, so
setting DELTA is up to the coder. It can be shown that depending on
the intensity of calculation/number of loops underflow errors can add
up to an arbitrary difference to the mathematical exact result. While
one usecase only values with a very small delta might be considered
equal, an other that e.g. knows the result of [mathematical complex
calulation] should be integer, it can safely use 0.5 as delta for
equality. etc.

On Tue, Nov 30, 2010 at 4:18 PM, steve donovan
<> wrote:
> On Tue, Nov 30, 2010 at 4:47 PM, Paul Hudson <> wrote:
>> Even more likely to trap the unwary, I'd have thought.
> Yes, such weird implementation details will only postpone the point
> when someone _really_ needs to understand floating-point!  The earlier
> the better; when they taught us FORTRAN IV they hammered the
> do-not-expect-floats-to-be-equal point home.
> steve d.