AndreSoYeah

Untitled

May 21st, 2015
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. num=7
  2. function toBits(num)
  3. -- returns a table of bits, least significant first.
  4. local t={} -- will contain the bits
  5. while num>0 do
  6. rest=math.fmod(num,2)
  7. t[#t+1]=rest
  8. num=(num-rest)/2
  9. end
  10. return t
  11. end
  12. bits=toBits(num)
  13. print(table.concat(bits))
Advertisement
Add Comment
Please, Sign In to add comment