summaryrefslogtreecommitdiff
path: root/src/lobject.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <giann008@gmail.com>2017-04-14 14:52:58 +0200
committerBenoit Giannangeli <giann008@gmail.com>2017-04-14 14:52:58 +0200
commit71a6b037db832205b54119de0769a48063d42550 (patch)
treee5278a582e5c61c2a6eb77327210c21192abf9d1 /src/lobject.js
parentc40f6b898cc36a1f6e2359946b524e46982d70f2 (diff)
downloadfengari-71a6b037db832205b54119de0769a48063d42550.tar.gz
fengari-71a6b037db832205b54119de0769a48063d42550.tar.bz2
fengari-71a6b037db832205b54119de0769a48063d42550.zip
Use Lua's modulo semantic
Diffstat (limited to 'src/lobject.js')
-rw-r--r--src/lobject.js2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/lobject.js b/src/lobject.js
index 710a906..aeaa105 100644
--- a/src/lobject.js
+++ b/src/lobject.js
@@ -540,7 +540,7 @@ const intarith = function(L, op, v1, v2) {
case lua.LUA_OPADD: return (v1 + v2);
case lua.LUA_OPSUB: return (v1 - v2);
case lua.LUA_OPMUL: return (v1 * v2);
- case lua.LUA_OPMOD: return (v1 % v2);
+ case lua.LUA_OPMOD: return (v1 - Math.floor(v1 / v2) * v2); // % semantic on negative numbers is different in js
case lua.LUA_OPIDIV: return (v1 / v2);
case lua.LUA_OPBAND: return (v1 & v2);
case lua.LUA_OPBOR: return (v1 | v2);