Skip to content

Instantly share code, notes, and snippets.

@echohes
Created August 22, 2022 10:03
Show Gist options
  • Save echohes/0b08e0fb412dd743bd8fd12a94eb0de1 to your computer and use it in GitHub Desktop.
Save echohes/0b08e0fb412dd743bd8fd12a94eb0de1 to your computer and use it in GitHub Desktop.
Convert int32 to binary
function conv_to_bin(x)
t={}
if x>0 then
while x>0 do
table.insert(t,x%2)
x=math.floor(x/2);
end
end
if #t<32 then
for i=1,32-#t do
table.insert(t,0)
end
end
return t
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment