From 7d930ec694dc079a252323d2136fbf4d49a49888 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 12 Mar 2015 11:04:04 -0300 Subject: use 'log2' when available --- lmathlib.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lmathlib.c') diff --git a/lmathlib.c b/lmathlib.c index 1925e826..466d2fe0 100644 --- a/lmathlib.c +++ b/lmathlib.c @@ -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 ** See Copyright Notice in lua.h */ @@ -183,6 +183,9 @@ static int math_log (lua_State *L) { res = l_mathop(log)(x); else { 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); else res = l_mathop(log)(x)/l_mathop(log)(base); } -- cgit v1.2.3-55-g6feb