Advertisement
BobMe

Binary Converter 2.0

Jan 23rd, 2020
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. -- There's actually a much more traditional way of converting a number to a decimal number, that is more efficient than my own method.
  2. -- So, time to try and make it (oh god it's so much cleaner)
  3.  
  4. -- Old Method: https://pastebin.com/Bq6yMnsz
  5.  
  6. number = 101 -- this will be the number to be converted
  7.  
  8. local bin = ""
  9. while number >= 1 do
  10. if number % 2 == 1 then
  11. number = number - 1
  12. number = number/2
  13. bin = "1"..bin
  14. else
  15. number = number / 2
  16. bin = "0"..bin
  17. end
  18. end
  19.  
  20. print(bin)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement