[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: reallycheckint(L,index)
- From: Roberto Ierusalimschy <roberto@...>
- Date: Wed, 29 May 2013 10:14:11 -0300
> [...] It was quite a shock
> to discover that luaL_checkint does not actually check that
> something is an integer.
Nothing checks whether something is an "integer", because Lua does
not have integers (yet ;). To check whether some value is a number,
you can use lua_type(L, index) == LUA_TNUMBER. To check whether that
number has an integer value, you can try
floor(lua_tonumber(L, index)) == lua_tonumber(L, index)
(I am calling lua_tonumber twice to avoid using a variable.) It is
up to you to decide whether inf/-inf are really integers.