lua-users home
lua-l archive

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


> [...] 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.

-- Roberto