Created
July 29, 2016 07:45
-
-
Save lexnewgate/28663fecae78324a87f38aa9c2e0a293 to your computer and use it in GitHub Desktop.
Lua- number to binary string
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
local function numberToBinStr(x) | |
ret="" | |
while x~=1 and x~=0 do | |
ret=tostring(x%2)..ret | |
x=math.modf(x/2) | |
end | |
ret=tostring(x)..ret | |
return ret | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment