Overflowing is actually intentional. I have a workaround by writing a 32-bit maths multiplication function:
local function mul32(a, b)
a = bit32.band(a, 0xffffffff);
b = bit32.band(b, 0xffffffff);
local ah = bit32.rshift(a, 16);
local bh = bit32.rshift(b, 16);
local al = bit32.band(a, 0xffff);
local bl = bit32.band(b, 0xffff);
local high = bit32.band((ah * bl) + (al * bh), 0xffff);
return bit32.band((high * 0x10000) + (al * bl), 0xffffffff);
end
It gets pathological from here because I might need to compose 64-bit multiplication out of this, given that I can't rely on Lua to behave with large numbers.