Created
August 22, 2022 10:03
-
-
Save echohes/0b08e0fb412dd743bd8fd12a94eb0de1 to your computer and use it in GitHub Desktop.
Convert int32 to binary
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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