revised callback system to use multiple arguments; added tobitstring function in utility

This commit is contained in:
Redo
2019-05-10 21:07:35 -05:00
parent 10611449bf
commit d2a648f7d9
3 changed files with 17 additions and 5 deletions

View File

@@ -51,3 +51,17 @@ function collapseescape(str)
return table.concat(ostrt)
end
function tobitstring(num, len)
local maxval = bit.lshift(1, len)
if num>=maxval then error("bitstring value too big") end
num = num%maxval
local bitstring = ""
for i = len, 1, -1 do
bitstring = bitstring..bit.rshift(bit.band(num, bit.lshift(1, i-1)), i-1)
end
return bitstring
end