aboutsummaryrefslogtreecommitdiff
path: root/lmathlib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2015-03-12 11:04:04 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2015-03-12 11:04:04 -0300
commit7d930ec694dc079a252323d2136fbf4d49a49888 (patch)
tree4d3db40260fb528b18db102be804e0e4015f87f8 /lmathlib.c
parent0cf3b6495a9eb58b7e50f43d633414aabab199af (diff)
downloadlua-7d930ec694dc079a252323d2136fbf4d49a49888.tar.gz
lua-7d930ec694dc079a252323d2136fbf4d49a49888.tar.bz2
lua-7d930ec694dc079a252323d2136fbf4d49a49888.zip
use 'log2' when available
Diffstat (limited to 'lmathlib.c')
-rw-r--r--lmathlib.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lmathlib.c b/lmathlib.c
index 1925e826..466d2fe0 100644
--- a/lmathlib.c
+++ b/lmathlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lmathlib.c,v 1.113 2014/11/07 11:31:58 roberto Exp roberto $ 2** $Id: lmathlib.c,v 1.114 2014/12/27 20:32:26 roberto Exp roberto $
3** Standard mathematical library 3** Standard mathematical library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -183,6 +183,9 @@ static int math_log (lua_State *L) {
183 res = l_mathop(log)(x); 183 res = l_mathop(log)(x);
184 else { 184 else {
185 lua_Number base = luaL_checknumber(L, 2); 185 lua_Number base = luaL_checknumber(L, 2);
186#if !defined(LUA_USE_C89)
187 if (base == 2.0) res = l_mathop(log2)(x); else
188#endif
186 if (base == 10.0) res = l_mathop(log10)(x); 189 if (base == 10.0) res = l_mathop(log10)(x);
187 else res = l_mathop(log)(x)/l_mathop(log)(base); 190 else res = l_mathop(log)(x)/l_mathop(log)(base);
188 } 191 }