|
On 1-Mar-05, at 8:41 AM, Roberto Ierusalimschy wrote:
What is wrong with the following code? math.nan = 0/0 math.inf = 1/0
If you've compiled Lua with integer Numbers rather than floating point ones, this will crash and burn, probably.
Personally, I think NaN should coerce to a boolean false; that would be much cleaner. (In fact, since NaN is not available as a table key, there is a good argument for just turning NaN's into nil).
math.isnan = function (x) return x ~= x endmath.isnotnan = ... -- beware: this one may be patented already ;)Put that in a file `nan.lua' and just say `require "nan"´.