Golden: @shantanuaryan67: exactly what I need but I need encoder and decoder lmao

shantanuaryan67: I used this in my ram. Converts binary to decimal and decimal to binary

function btd(bin) -- converts binary to decimal
i=0
dec=0
while i<8
do dec=dec+(bin%10)*(2^i)
x=math.floor(bin/10)
i=i+1
end
return dec
end
function dtb(dec) -- converts decimal to binary
i=0
bin=0
while i<8
do bin=(math.floor(dec/(2^(7-i))))*(10^(7-i))+bin
dec=dec%(2^(7-i))
i=i+1
end
return bin
end

HXCTCreations: @Golden: maybe i can compress the signal in my decoder..

Golden: @HXCTcreations: could you make one Lua that can encode and decode at same time?

## Discuss this level

function btd(bin) -- converts binary to decimal

i=0

dec=0

while i<8

do dec=dec+(bin%10)*(2^i)

x=math.floor(bin/10)

i=i+1

end

return dec

end

function dtb(dec) -- converts decimal to binary

i=0

bin=0

while i<8

do bin=(math.floor(dec/(2^(7-i))))*(10^(7-i))+bin

dec=dec%(2^(7-i))

i=i+1

end

return bin

end