1const convertNumberToBinary = number => {
2 return (number >>> 0).toString(2);
3}
4
1/* From decimal to binary (similar fo rother base) */
2const num = 7;
3num.toString(2); // output: "111"
4
5/* From binary (similar fo rother base) to decimal */
6parseInt("111", 2); // output: 7
1function bin(num) {
2 var binn = [];
3 var c;
4 while (num != 1) {
5 c = Math.floor(num / 2);
6 binn.unshift(num % 2);
7 num = c;
8
9 }
10 binn.unshift(1)
11 return binn
12}
13//returns list of binary nos. in order
14