diff options
| author | William Wilgus <me.theuser@yahoo.com> | 2018-11-08 11:32:45 -0500 |
|---|---|---|
| committer | William Wilgus <me.theuser@yahoo.com> | 2018-11-11 19:42:30 -0500 |
| commit | b69faf0bcc5ddca1d88b1a7ab47bcbbc6dbb9af1 (patch) | |
| tree | 191277cab3ef773238c1e91dafaaea04ddca1949 /apps/plugins/lua/lmathlib.c | |
| parent | de6618a2713ef26f888762cbe6539cc65a393c7c (diff) | |
| download | rockbox-b69faf0bcc5ddca1d88b1a7ab47bcbbc6dbb9af1.zip rockbox-b69faf0bcc5ddca1d88b1a7ab47bcbbc6dbb9af1.tar.gz rockbox-b69faf0bcc5ddca1d88b1a7ab47bcbbc6dbb9af1.tar.bz2 rockbox-b69faf0bcc5ddca1d88b1a7ab47bcbbc6dbb9af1.tar.xz | |
lua update to 5.1.5
Modify Rocklua towards upstream 5.1.5
Clean up some of the Rocklua implementation
Change-Id: Iac722e827899cf84f5ca004ef7ae7ddce5f7fbbe
Diffstat (limited to 'apps/plugins/lua/lmathlib.c')
| -rw-r--r-- | apps/plugins/lua/lmathlib.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/apps/plugins/lua/lmathlib.c b/apps/plugins/lua/lmathlib.c index 99a1040..56c79af 100644 --- a/apps/plugins/lua/lmathlib.c +++ b/apps/plugins/lua/lmathlib.c @@ -82,19 +82,17 @@ static int math_atan2 (lua_State *L) { lua_pushnumber(L, atan2(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); return 1; } -#endif static int math_ceil (lua_State *L) { - /* Doesn't change anything in fixed point arithmetic */ - lua_pushnumber(L, luaL_checknumber(L, 1)); + lua_pushnumber(L, ceil(luaL_checknumber(L, 1))); return 1; } static int math_floor (lua_State *L) { - /* Doesn't change anything in fixed point arithmetic */ - lua_pushnumber(L, luaL_checknumber(L, 1)); + lua_pushnumber(L, floor(luaL_checknumber(L, 1))); return 1; } +#endif static int math_fmod (lua_State *L) { /* Was: lua_pushnumber(L, fmod(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); */ @@ -220,6 +218,11 @@ static int math_randomseed (lua_State *L) { return 0; } +static int math_ident (lua_State *L) { /* ROCKLUA ADDED */ + /* Ceil & floor Doesn't change anything in fixed point arithmetic */ + lua_pushnumber(L, luaL_checknumber(L, 1)); + return 1; +} static const luaL_Reg mathlib[] = { {"abs", math_abs}, @@ -228,17 +231,15 @@ static const luaL_Reg mathlib[] = { {"asin", math_asin}, {"atan2", math_atan2}, {"atan", math_atan}, -#endif {"ceil", math_ceil}, -#if 0 {"cosh", math_cosh}, {"cos", math_cos}, #endif {"deg", math_deg}, #if 0 {"exp", math_exp}, -#endif {"floor", math_floor}, +#endif {"fmod", math_fmod}, #if 0 {"frexp", math_frexp}, @@ -262,6 +263,8 @@ static const luaL_Reg mathlib[] = { {"tanh", math_tanh}, {"tan", math_tan}, #endif + {"ceil", math_ident}, + {"floor", math_ident}, {NULL, NULL} }; |