|
As someone with little math background it seem logical that the language should have a built in test for this as the implementation details of testing for NaN are outside the scope of most people's understanding, yet it is something that is important to test for. This train of thought would support Mr. Hinds argument that it should be considered a numerical subtype that would return a distinguished value. if type(x) ~= 'nan' then ... end Russ Sent from my BlackBerry 10 smartphone on the Virgin Mobile network.
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 |