aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-05-16 17:53:58 +1000
committerdaurnimator <quae@daurnimator.com>2017-05-16 17:53:58 +1000
commit080bb741b521ec8ff472ca239003b43860315c9a (patch)
treefe8a9223a040ee61727268f3800840714e13fd87
parent1358ae72c9814ed34bce7300182c796c2e910ead (diff)
downloadfengari-080bb741b521ec8ff472ca239003b43860315c9a.tar.gz
fengari-080bb741b521ec8ff472ca239003b43860315c9a.tar.bz2
fengari-080bb741b521ec8ff472ca239003b43860315c9a.zip
src/lobject.js: IDIV is floor division
-rw-r--r--src/lobject.js4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lobject.js b/src/lobject.js
index 52e9712..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);
@@ -543,7 +543,7 @@ 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);