diff --git a/src/jse/org/luaj/vm2/lib/jse/JseMathLib.java b/src/jse/org/luaj/vm2/lib/jse/JseMathLib.java index fde2f257..87f133a1 100644 --- a/src/jse/org/luaj/vm2/lib/jse/JseMathLib.java +++ b/src/jse/org/luaj/vm2/lib/jse/JseMathLib.java @@ -98,7 +98,14 @@ public class JseMathLib extends org.luaj.vm2.lib.MathLib { } static final class cosh extends UnaryOp { protected double call(double d) { return Math.cosh(d); } } static final class exp extends UnaryOp { protected double call(double d) { return Math.exp(d); } } - static final class log extends UnaryOp { protected double call(double d) { return Math.log(d); } } + static final class log extends TwoArgFunction { + public LuaValue call(LuaValue x, LuaValue base) { + double nat = Math.log(x.checkdouble()); + double b = base.optdouble(Math.E); + if (b != Math.E) nat /= Math.log(b); + return valueOf(nat); + } + } static final class pow extends BinaryOp { protected double call(double x, double y) { return Math.pow(x, y); } } static final class sinh extends UnaryOp { protected double call(double d) { return Math.sinh(d); } } static final class tanh extends UnaryOp { protected double call(double d) { return Math.tanh(d); } }