Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function dec2bin(num){
- var arr = [] , rem =0 , count = "";
- var n = num;
- while( n > 0){
- rem = Math.floor(n % 2);
- arr.push(rem);
- n = Math.floor(n /2);
- }
- //alert(arr);
- while(arr.length !==0){
- count += arr.pop();
- }
- return count;
- }
- alert(dec2bin(10));
Add Comment
Please, Sign In to add comment