-
-
Save brovish/a3aeb3e581f5ae71eda301ab568b003b to your computer and use it in GitHub Desktop.
Lua- number to binary string
This file contains hidden or 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