Created
August 22, 2022 10:08
-
-
Save echohes/a691d32b4ac3bbaf98a1c61a6effad7a to your computer and use it in GitHub Desktop.
Convert binary to int
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
--a binary number is represented as values in a table | |
t_bin = {1,0,0,0,0,0,0,0} | |
function bin_to_in(x) | |
r=0 | |
for k,v in pairs(x) do | |
r = r + (v*2^(8-k)) | |
end | |
return math.floor(r) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment