2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -1,11 +1,10 @@
|
|||
function dec2bin (n)
|
||||
local bin, number, bit = "", tonumber(n) -- can pass n as string
|
||||
while number > 0 do
|
||||
bit = number % 2
|
||||
number = math.floor(number/2)
|
||||
bin = bit .. bin
|
||||
end
|
||||
return bin
|
||||
local bin = ""
|
||||
while n > 0 do
|
||||
bin = n % 2 .. bin
|
||||
n = math.floor(n / 2)
|
||||
end
|
||||
return bin
|
||||
end
|
||||
|
||||
print(dec2bin(5))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue