Advertisement
BobMe

binary thing

Nov 15th, 2019
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. -- Im learning how to use binary and I learned that binary is in powers of 2, so to find out minecraft's floating point errors, I made this.
  2.  
  3. number = 16383 -- This is the number you want to change to convert to binary
  4.  
  5. did = 10000 -- don chang or ban
  6.  
  7. --cached numbers
  8. bin = ""
  9. kek = did
  10.  
  11. for i=1,did do
  12. if number % 2^(did-i) ~= number then
  13. number = number - 2^(did-i)
  14. bin = bin.."1"
  15. else
  16. bin = bin.."0"
  17. end
  18. end
  19.  
  20. for i=1,#bin do -- get rid of those pesky gross zeros
  21. if string.sub(bin,i,i) == "1" then
  22. bin = string.sub(bin,i)
  23. break
  24. end
  25. end
  26. print(bin.." | "..number)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement