diff options
author | Lua Team <team@lua.org> | 2005-09-09 12:00:00 +0000 |
---|---|---|
committer | repogen <> | 2005-09-09 12:00:00 +0000 |
commit | bd80c4ee9b6d9464cf9f3ff4ee41890d8b3ca9e6 (patch) | |
tree | e1d7c1b341ccb9a3a1fb044ac6e67b5a5e0259b7 /src/lmathlib.c | |
parent | bf6b5550cdfbc0c4a3a4577776ad76628d80718e (diff) | |
download | lua-github-5.1-alpha.tar.gz |
Lua 5.1-alpha5.1-alpha
Diffstat (limited to 'src/lmathlib.c')
-rw-r--r-- | src/lmathlib.c | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/src/lmathlib.c b/src/lmathlib.c index bba99b0d..d181a731 100644 --- a/src/lmathlib.c +++ b/src/lmathlib.c @@ -1,5 +1,5 @@ /* -** $Id: lmathlib.c,v 1.63 2005/03/04 18:57:03 roberto Exp $ +** $Id: lmathlib.c,v 1.67 2005/08/26 17:36:32 roberto Exp $ ** Standard mathematical library ** See Copyright Notice in lua.h */ @@ -88,7 +88,7 @@ static int math_floor (lua_State *L) { return 1; } -static int math_mod (lua_State *L) { +static int math_fmod (lua_State *L) { lua_pushnumber(L, fmod(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); return 1; } @@ -212,35 +212,35 @@ static int math_randomseed (lua_State *L) { } -static const luaL_reg mathlib[] = { +static const luaL_Reg mathlib[] = { {"abs", math_abs}, - {"sin", math_sin}, - {"sinh", math_sinh}, - {"cos", math_cos}, - {"cosh", math_cosh}, - {"tan", math_tan}, - {"tanh", math_tanh}, - {"asin", math_asin}, {"acos", math_acos}, - {"atan", math_atan}, + {"asin", math_asin}, {"atan2", math_atan2}, + {"atan", math_atan}, {"ceil", math_ceil}, + {"cosh", math_cosh}, + {"cos", math_cos}, + {"deg", math_deg}, + {"exp", math_exp}, {"floor", math_floor}, - {"mod", math_mod}, - {"modf", math_modf}, + {"fmod", math_fmod}, {"frexp", math_frexp}, {"ldexp", math_ldexp}, - {"sqrt", math_sqrt}, - {"min", math_min}, - {"max", math_max}, - {"log", math_log}, {"log10", math_log10}, - {"exp", math_exp}, - {"deg", math_deg}, + {"log", math_log}, + {"max", math_max}, + {"min", math_min}, + {"modf", math_modf}, {"pow", math_pow}, {"rad", math_rad}, {"random", math_random}, {"randomseed", math_randomseed}, + {"sinh", math_sinh}, + {"sin", math_sin}, + {"sqrt", math_sqrt}, + {"tanh", math_tanh}, + {"tan", math_tan}, {NULL, NULL} }; @@ -249,11 +249,15 @@ static const luaL_reg mathlib[] = { ** Open math library */ LUALIB_API int luaopen_math (lua_State *L) { - luaL_openlib(L, LUA_MATHLIBNAME, mathlib, 0); + luaL_register(L, LUA_MATHLIBNAME, mathlib); lua_pushnumber(L, PI); lua_setfield(L, -2, "pi"); lua_pushnumber(L, HUGE_VAL); lua_setfield(L, -2, "huge"); +#if defined(LUA_COMPAT_MOD) + lua_getfield(L, -1, "fmod"); + lua_setfield(L, -2, "mod"); +#endif return 1; } |