lua-users home
lua-l archive

Re: simple question about NaN and FP exceptions

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


On 2011年2月21日, Axel Kittenberger wrote:
>
> Would it be too much compatibility breaking or performance impacting
> to have NaN evaluate itself to boolean false instead of true by
> default?
Try it :-)
Note that there is a luai_numisnan() macro defined in luaconf.h but it
takes the Lua context pointer as an argument so I could not use it here.
--- a/src/lobject.h
+++ b/src/lobject.h
@@ -121,7 +121,7 @@ typedef struct lua_TValue {
 #define bvalue(o) check_exp(ttisboolean(o), (o)->value_.b)
 #define thvalue(o) check_exp(ttisthread(o), &(o)->value_.gc->th)
-#define l_isfalse(o) (ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0))
+#define l_isfalse(o) (ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0) || (ttisnumber(o) && !luai_numeq((o),(o))))
 #define iscollectable(o) (ttype(o) >= LUA_TSTRING)
Tony.
-- 
f.anthony.n.finch <dot@dotat.at> http://dotat.at/
Shannon: Mainly southwesterly 4 or 5, occasionally 6. Rough or very rough.
Rain or showers. Moderate or good, occasionally poor.

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