lua-users home
lua-l archive

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


On 11/7/2010 4:27 AM, A.S. Bradbury wrote:
On 6 November 2010 14:08, Mike McGonagle wrote:
Not trying to dredge up this topic again, but I can't quite seem to
find the "definitive" method of making this test. Currently my
programs are just throwing errors and stopping, I would like to be
able to detect when this happens, discard the results, and then move
on to the next iteration of my program.

Luiz's lmathx [1] provides isnan and fpclassify if you prefer which is
certainly definitive as it just gives you access to the C99 math
additions. Alternatively, testing x ~= x on a Lua number is correct
(and this is how the internal luai_numisnan macro is defined).

Curious about the functions Mike is using... Assuming we are running in Lua, we don't have to take extreme performance measures like cycle- or instruction-counting.

If we add a test or two at suitable locations for values and calculations leading to NaNs (since they are generated for good, uncommon reasons) and throw errors if necessary, is that significantly worse than checking for result NaNs?

--
Cheers,
Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia