[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Infinity as index
- From: Dirk Laurie <dirk.laurie@...>
- Date: Thu, 24 Apr 2014 18:15:00 +0200
2014-04-24 1:19 GMT+02:00 Rena <hyperhacker@gmail.com>:
> lua_isnan(L, n): returns true if the value at index n is NaN.
> lua_isinfinity(L, n): returns 1 if the value at index n is infinity, -1 if the value is -infinity, and 0 otherwise.
I don't think we need that at the C API level.
In Lua, there are standard idioms:
if x~=x then -- x is NaN
if 1/x == 0 then -- x is inf or -inf
if x==1/0 then -- x is inf
if x==-1/0 then -- x is -inf
if x==0 then -- x is 0 or -0
The hardest test of all is to distinguish between 0 and -0.
If you can improve on the following, please post.
if x==0 and 1/x>0 then -- x is 0
if x==0 and 1/x<0 then -- x is -0