function dtb(num)
local bin=""
for i=1,8do
bin..=flr(num/2^(8-i))%2
end
return bin
end
P#101661 2021-12-06 21:22
1
This might be something to have in future Pico-8, the ability to convert to binary thus:
TOSTR(VAL, [FORMAT_FLAGS])
print(tostr(254,3))
11111110
You can do the function with BAND too if you like, that's how I do it:
function dtb2(num) local bin="" for i=0,7 do bin..=band(num,2^i)\2^i end return bin end |
28-tokens
P#101693 2021-12-06 23:14 ( Edited 2021-12-06 23:29)
[Please log in to post a comment]