mirror of
https://github.com/lua/lua
synced 2025-03-23 14:12:52 +03:00
use 'log2' when available
This commit is contained in:
parent
0cf3b6495a
commit
7d930ec694
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lmathlib.c,v 1.113 2014/11/07 11:31:58 roberto Exp roberto $
|
** $Id: lmathlib.c,v 1.114 2014/12/27 20:32:26 roberto Exp roberto $
|
||||||
** Standard mathematical library
|
** Standard mathematical library
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -183,6 +183,9 @@ static int math_log (lua_State *L) {
|
|||||||
res = l_mathop(log)(x);
|
res = l_mathop(log)(x);
|
||||||
else {
|
else {
|
||||||
lua_Number base = luaL_checknumber(L, 2);
|
lua_Number base = luaL_checknumber(L, 2);
|
||||||
|
#if !defined(LUA_USE_C89)
|
||||||
|
if (base == 2.0) res = l_mathop(log2)(x); else
|
||||||
|
#endif
|
||||||
if (base == 10.0) res = l_mathop(log10)(x);
|
if (base == 10.0) res = l_mathop(log10)(x);
|
||||||
else res = l_mathop(log)(x)/l_mathop(log)(base);
|
else res = l_mathop(log)(x)/l_mathop(log)(base);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user