Stary2001

Untitled

Jul 20th, 2012
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.18 KB | None | 0 0
  1. function num2bin(n,b)
  2. local s=""
  3. for i=b-1,0,-1 do
  4. local po2 = math.pow(2,i)
  5. if n/po2 >=1 then
  6. s=s.."1"
  7. n=n-po2
  8. else s=s.."0" end
  9. print(i,po2)
  10. end
  11. return s
  12. end
Advertisement
Add Comment
Please, Sign In to add comment