Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Bin2Dec(s)
- local num = 0
- local ex = string.len(s) - 1
- local l = 0
- l = ex + 1
- for i = 1, l do
- b = string.sub(s, i, i)
- if b == "1" then
- num = num + 2^ex
- end
- ex = ex - 1
- end
- return string.format("%u", num)
- end
Advertisement
Add Comment
Please, Sign In to add comment