From d6e4dc3e7684f32c614fa26b6d66eab57e64eb86 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Mon, 22 May 2017 15:56:07 +1000 Subject: src/lmathlib.js: math.ult needs to compare as if integers are unsigned --- src/lmathlib.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lmathlib.js b/src/lmathlib.js index 0c3b715..b10f7bf 100644 --- a/src/lmathlib.js +++ b/src/lmathlib.js @@ -129,7 +129,9 @@ const math_sqrt = function(L) { const math_ult = function(L) { let a = lauxlib.luaL_checkinteger(L, 1); let b = lauxlib.luaL_checkinteger(L, 2); - lua.lua_pushboolean(L, Math.abs(a) < Math.abs(b)); + if (a < 0) a += 4294967296; + if (b < 0) b += 4294967296; + lua.lua_pushboolean(L, a < b); return 1; }; -- cgit v1.2.3-54-g00ecf