diff options
Diffstat (limited to 'src/lobject.js')
-rw-r--r-- | src/lobject.js | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/lobject.js b/src/lobject.js index 9790d23..680e293 100644 --- a/src/lobject.js +++ b/src/lobject.js @@ -523,7 +523,7 @@ const intarith = function(L, op, v1, v2) { case defs.LUA_OPSUB: return (v1 - v2)|0; case defs.LUA_OPMUL: return (v1 * v2)|0; case defs.LUA_OPMOD: return (v1 - Math.floor(v1 / v2) * v2)|0; // % semantic on negative numbers is different in js - case defs.LUA_OPIDIV: return (v1 / v2)|0; + case defs.LUA_OPIDIV: return Math.floor(v1 / v2)|0; case defs.LUA_OPBAND: return (v1 & v2); case defs.LUA_OPBOR: return (v1 | v2); case defs.LUA_OPBXOR: return (v1 ^ v2); @@ -531,6 +531,7 @@ const intarith = function(L, op, v1, v2) { case defs.LUA_OPSHR: return (v1 >> v2); case defs.LUA_OPUNM: return (0 - v1)|0; case defs.LUA_OPBNOT: return (~0 ^ v1); + default: assert(0); } }; @@ -542,9 +543,10 @@ const numarith = function(L, op, v1, v2) { case defs.LUA_OPMUL: return v1 * v2; case defs.LUA_OPDIV: return v1 / v2; case defs.LUA_OPPOW: return Math.pow(v1, v2); - case defs.LUA_OPIDIV: return (v1 / v2); + case defs.LUA_OPIDIV: return Math.floor(v1 / v2); case defs.LUA_OPUNM: return -v1; case defs.LUA_OPMOD: return v1 % v2; + default: assert(0); } }; |