From 080bb741b521ec8ff472ca239003b43860315c9a Mon Sep 17 00:00:00 2001 From: daurnimator Date: Tue, 16 May 2017 17:53:58 +1000 Subject: src/lobject.js: IDIV is floor division --- src/lobject.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') 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); -- cgit v1.2.3-70-g09d2