I've just finished implementing a full method to do division using byte tables. Thanks for the help Bomb Bloke
local function floorDiv(a, b) -- Returns the quotient and the remainder
local result = {}
local current = copyTable(b)
local values = {current}
local lsh = 1
while compare(a, current) > 0 do -- Find the largest value
print(tostring(lsh).."> "..toHexString(current))
current = add(current, current)
lsh = lsh + 1
values[lsh] = current
end
current = copyTable(a)
while lsh > 0 and compare(current, {0}) > 0 do
if compare(current, values[lsh]) >= 0 then
local index = math.floor((lsh - 1) / 8) + 1
result[index] = bit32.bor(result[index] or 0, bit32.lshift(1, lsh - 1))
current = subtract(current, values[lsh])
end
lsh = lsh - 1
end
return result, current
end
In case you're curious, it uses a method I manually came up with which is to perform bit-by-bit division by subtracting from the number every time it can. If it does subtract, it also sets the bit inside the result. It does this until it has checked all bits or the remainder is 0 and then returns.
Edited by CrazyPyroEagle, 08 July 2016 - 08:29 AM.