[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: checking for Not a Number?
- From: Rici Lake <lua@...>
- Date: Fri, 29 Dec 2006 19:40:33 -0500
On 29-Dec-06, at 6:10 PM, Joe Smith wrote:
I'm still not sure that this code is correct:
else if (ttisnumber(key) && nvalue(key) != nvalue(key))
luaG_runerror(L, "table index is NaN");
If nvalue(key) was stored in a varible, which was compaired to itself,
then I would agree that it
would be required to do the right thing.
nvalue(key) is actually a macro which access the numeric value from a
union in the struct which key points to. So it's completely safe.
Even if the value were widened in one of the expansions and not in the
other, the comparison would still work as expected since widening
cannot alter the value.