From bdaa2a67b491bfc1d9521778cb3d13d386f97f93 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Sun, 21 May 2017 18:56:10 +1000 Subject: Use same mod operator behaviour from both lvm.js and lobject.js --- src/llimit.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/llimit.js') diff --git a/src/llimit.js b/src/llimit.js index c8455b8..31862d0 100644 --- a/src/llimit.js +++ b/src/llimit.js @@ -8,6 +8,14 @@ module.exports.LUA_MAXINTEGER = LUA_MAXINTEGER; const LUA_MININTEGER = -2147483648; module.exports.LUA_MININTEGER = LUA_MININTEGER; +const luai_nummod = function(L, a, b) { + let m = a % b; + if ((m*b) < 0) + m += b; + return m; +}; +module.exports.luai_nummod = luai_nummod; + // If later integers are more than 32bit, LUA_MAXINTEGER will then be != MAX_INT const MAX_INT = 2147483647; module.exports.MAX_INT = MAX_INT; -- cgit v1.2.3-54-g00ecf