Guest User

Untitled

a guest
Nov 22nd, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. function dec2bin(num){
  2. var arr = [] , rem =0 , count = "";
  3. var n = num;
  4.  
  5. while( n > 0){
  6. rem = Math.floor(n % 2);
  7. arr.push(rem);
  8. n = Math.floor(n /2);
  9. }
  10. //alert(arr);
  11. while(arr.length !==0){
  12. count += arr.pop();
  13. }
  14. return count;
  15. }
  16. alert(dec2bin(10));
Add Comment
Please, Sign In to add comment