Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- binary to interger yes?
- number = "1010011010"
- countup = 0
- function removedeci(x)
- local y = tostring(x)
- for i=1,#y do
- if string.sub(y,i,i+1) == ".0" then
- return tonumber(string.sub(y,1,i-1))
- end
- end
- return(x)
- end
- for i=1,#number do
- if string.sub(number,i,i) == "1" then
- countup = countup+2^((#number-i))
- end
- end
- print(#number.." bit, "..removedeci(countup))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement