lua-users home
lua-l archive

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


> Directly compairing floating point numbers for equality is *always* a bad 
> idea.

Only if the numbers are supposed to be the same number but are the result
of two different computations.

> For example, you can find that a floating point value which is not a
> NaN is not equal to itself.

I find this very surprising. And possibily wrong, ie against IEEE 754.
The explanation that followed made no sense to me. It would make sense for
floating point values held in *different* variables, but not for the *same*
variable. It seems to me that the gcc docs is spreading unnecessary FUD.
But I must be missing something...

> Why was the ISO C standard macro "isnan(_real-floating_ x)" not used?

Because isnan is in C99 but not in C89, which is what Lua assumes.
--lhf