mirror of https://github.com/rusefi/lua.git
'math.ifloor' is back
This commit is contained in:
parent
3fc25ff15b
commit
e3871abe95
16
lmathlib.c
16
lmathlib.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lmathlib.c,v 1.101 2014/05/26 17:13:52 roberto Exp roberto $
|
** $Id: lmathlib.c,v 1.102 2014/06/02 23:09:28 roberto Exp roberto $
|
||||||
** Standard mathematical library
|
** Standard mathematical library
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -76,6 +76,19 @@ static int math_atan (lua_State *L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int math_ifloor (lua_State *L) {
|
||||||
|
int valid;
|
||||||
|
lua_Integer n = lua_tointegerx(L, 1, &valid);
|
||||||
|
if (valid)
|
||||||
|
lua_pushinteger(L, n); /* floor computed by Lua */
|
||||||
|
else {
|
||||||
|
luaL_checktype(L, 1, LUA_TNUMBER); /* argument must be a number */
|
||||||
|
lua_pushnil(L); /* number is not convertible to integer */
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int math_floor (lua_State *L) {
|
static int math_floor (lua_State *L) {
|
||||||
int valid;
|
int valid;
|
||||||
lua_Integer n = lua_tointegerx(L, 1, &valid);
|
lua_Integer n = lua_tointegerx(L, 1, &valid);
|
||||||
|
@ -326,6 +339,7 @@ static const luaL_Reg mathlib[] = {
|
||||||
{"cos", math_cos},
|
{"cos", math_cos},
|
||||||
{"deg", math_deg},
|
{"deg", math_deg},
|
||||||
{"exp", math_exp},
|
{"exp", math_exp},
|
||||||
|
{"ifloor", math_ifloor},
|
||||||
{"floor", math_floor},
|
{"floor", math_floor},
|
||||||
{"fmod", math_fmod},
|
{"fmod", math_fmod},
|
||||||
{"log", math_log},
|
{"log", math_log},
|
||||||
|
|
Loading…
Reference in New Issue