lua-users home
lua-l archive

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


Hi,

The (odd) requirement of the IEEE standard that NaN not test equal to itself means that there is no (robust) way to test for NaN from Lua

Wouldn't this be enough?

    function isNan(x)
      return x ~= x
    end

Or if you want something a bit more resistant against tables with metatable magic:

    function isNan(x)
      return type(x) == 'number' and x ~= x
    end