mirror of
https://github.com/minetest-mods/MoreMesecons.git
synced 2025-01-01 10:17:33 +01:00
refactor to_bits
This commit is contained in:
parent
332517912d
commit
858b23b28d
15
md5.lua
15
md5.lua
@ -100,15 +100,12 @@ else
|
||||
-- to bits table
|
||||
local tbl = {}
|
||||
local cnt = 1
|
||||
while (n > 0) do
|
||||
local last = math.mod(n,2)
|
||||
if(last == 1) then
|
||||
tbl[cnt] = 1
|
||||
else
|
||||
tbl[cnt] = 0
|
||||
end
|
||||
n = (n-last)/2
|
||||
cnt = cnt + 1
|
||||
local last
|
||||
while n > 0 do
|
||||
last = n % 2
|
||||
tbl[cnt] = last
|
||||
n = (n-last)/2
|
||||
cnt = cnt + 1
|
||||
end
|
||||
|
||||
return tbl
|
||||
|
Loading…
Reference in New Issue
Block a user