From 71a6b037db832205b54119de0769a48063d42550 Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Fri, 14 Apr 2017 14:52:58 +0200 Subject: Use Lua's modulo semantic --- src/lvm.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/lvm.js') diff --git a/src/lvm.js b/src/lvm.js index 6febe4b..500c2e8 100644 --- a/src/lvm.js +++ b/src/lvm.js @@ -281,9 +281,9 @@ const luaV_execute = function(L) { let numberop2 = tonumber(op2); if (op1.ttisinteger() && op2.ttisinteger()) { - L.stack[ra] = new TValue(CT.LUA_TNUMINT, (op1.value % op2.value)); + L.stack[ra] = new TValue(CT.LUA_TNUMINT, (op1.value - Math.floor(op1.value / op2.value) * op2.value)); } else if (numberop1 !== false && numberop2 !== false) { - L.stack[ra] = new TValue(CT.LUA_TNUMFLT, k[i.B].value % op2.value); + L.stack[ra] = new TValue(CT.LUA_TNUMFLT, (numberop1 - Math.floor(numberop1 / numberop2) * numberop2)); } else { ltm.luaT_trybinTM(L, op1, op2, ra, ltm.TMS.TM_MOD); base = ci.u.l.base; -- cgit v1.2.3-54-g00ecf