summaryrefslogtreecommitdiff
path: root/src/lobject.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-05-21 19:07:37 +1000
committerdaurnimator <quae@daurnimator.com>2017-05-21 20:20:18 +1000
commit9bd802f91c02b7f9ed1241e7be1266a429ba0cf9 (patch)
treeff58c241d8d4c7d73593ab409b878d7fee743ca9 /src/lobject.js
parentc09ab00b85677881f0ca0424b27ad14521e4a770 (diff)
downloadfengari-9bd802f91c02b7f9ed1241e7be1266a429ba0cf9.tar.gz
fengari-9bd802f91c02b7f9ed1241e7be1266a429ba0cf9.tar.bz2
fengari-9bd802f91c02b7f9ed1241e7be1266a429ba0cf9.zip
Centralise integer mod and div operations to luaV_mod and luaV_div
Diffstat (limited to 'src/lobject.js')
-rw-r--r--src/lobject.js4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lobject.js b/src/lobject.js
index 6d86852..0898a15 100644
--- a/src/lobject.js
+++ b/src/lobject.js
@@ -522,8 +522,8 @@ const intarith = function(L, op, v1, v2) {
case defs.LUA_OPADD: return (v1 + v2)|0;
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 Math.floor(v1 / v2)|0;
+ case defs.LUA_OPMOD: return lvm.luaV_mod(L, v1, v2);
+ case defs.LUA_OPIDIV: return lvm.luaV_div(L, v1, v2);
case defs.LUA_OPBAND: return (v1 & v2);
case defs.LUA_OPBOR: return (v1 | v2);
case defs.LUA_OPBXOR: return (v1 ^ v2);