From b9f9cde1c18ace3930be4cb7f6d9527178544d8b Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Mon, 24 Apr 2017 15:00:52 +0200 Subject: Force 32bit integer with |0 --- src/lobject.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/lobject.js') diff --git a/src/lobject.js b/src/lobject.js index 7409415..0f71405 100644 --- a/src/lobject.js +++ b/src/lobject.js @@ -524,11 +524,11 @@ const luaO_int2fb = function(x) { const intarith = function(L, op, v1, v2) { switch (op) { - 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 - Math.floor(v1 / v2) * v2); // % semantic on negative numbers is different in js - case lua.LUA_OPIDIV: return (v1 / v2); + case lua.LUA_OPADD: return (v1 + v2)|0; + case lua.LUA_OPSUB: return (v1 - v2)|0; + case lua.LUA_OPMUL: return (v1 * v2)|0; + case lua.LUA_OPMOD: return (v1 - Math.floor(v1 / v2) * v2)|0; // % semantic on negative numbers is different in js + case lua.LUA_OPIDIV: return (v1 / v2)|0; case lua.LUA_OPBAND: return (v1 & v2); case lua.LUA_OPBOR: return (v1 | v2); case lua.LUA_OPBXOR: return (v1 ^ v2); -- cgit v1.2.3-54-g00ecf