revised callback system to use multiple arguments; added tobitstring function in utility
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user