Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function decBin(dec)
- local result = " "
- repeat
- local divres = dec / 2
- local int, frac = math.modf(divres)
- dec = int
- result = math.ceil(frac) .. result
- until dec == 0
- local StrNumber
- StrNumber = string.format(result, "s")
- local nbZero
- nbZero = 16 - string.len(StrNumber)
- local Sresult
- Sresult = string.rep("0", nbZero)..StrNumber
- return Sresult
- end
- function binDec(bin)
- local num = 0
- local ex = string.len(bin) - 1
- local l = 0
- l = ex + 1
- for i = 1, l do
- b = string.sub(bin, i ,i)
- if b == "1" then
- num = num + 2^ex
- end
- ex = ex - 1
- end
- return num
- end
- term.setCursorPos(1,1)
- term.write("Please type a message to be sent.")
- term.setCursorPos(1,2)
- local input = read()
- local textLength = string.len(input)
Advertisement
Add Comment
Please, Sign In to add comment