mirror of
https://github.com/lua/lua
synced 2025-02-24 09:04:02 +03:00
math.log now accepts an optional base
This commit is contained in:
parent
33e7bc88f8
commit
5019b2dd20
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lmathlib.c,v 1.66 2005/08/15 14:12:32 roberto Exp roberto $
|
||||
** $Id: lmathlib.c,v 1.67 2005/08/26 17:36:32 roberto Exp roberto $
|
||||
** Standard mathematical library
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -112,7 +112,10 @@ static int math_pow (lua_State *L) {
|
||||
}
|
||||
|
||||
static int math_log (lua_State *L) {
|
||||
lua_pushnumber(L, log(luaL_checknumber(L, 1)));
|
||||
lua_Number res = log(luaL_checknumber(L, 1));
|
||||
if (!lua_isnoneornil(L, 2))
|
||||
res /= log(luaL_checknumber(L, 2));
|
||||
lua_pushnumber(L, res);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user