lua-users home
lua-l archive

Re: Some small requests for the next release

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


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 end
math.isnotnan = ... -- beware: this one may be patented already ;)
Put that in a file `nan.lua' and just say `require "nan"´.

AltStyle によって変換されたページ (->オリジナル) /