summaryrefslogtreecommitdiff
path: root/src/lobject.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <giann008@gmail.com>2017-04-24 15:00:52 +0200
committerBenoit Giannangeli <giann008@gmail.com>2017-04-24 15:00:52 +0200
commitb9f9cde1c18ace3930be4cb7f6d9527178544d8b (patch)
tree366aff341c05bcc8115b97bec042f51776d4a138 /src/lobject.js
parent656758c86ad929b07bb6422eb0f44cf9f2347aac (diff)
downloadfengari-b9f9cde1c18ace3930be4cb7f6d9527178544d8b.tar.gz
fengari-b9f9cde1c18ace3930be4cb7f6d9527178544d8b.tar.bz2
fengari-b9f9cde1c18ace3930be4cb7f6d9527178544d8b.zip
Force 32bit integer with |0
Diffstat (limited to 'src/lobject.js')
-rw-r--r--src/lobject.js10
1 files changed, 5 insertions, 5 deletions
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);