Last Updated: February 25, 2016
·
454
· netzzwerg

Decimal to Binary

var decimal = 123;
var remainder;
var binary = [];

while (decimal > 0) {
    remainder = decimal % 2;
    decimal = (decimal / 2) >> 0;
    binary.unshift(remainder);
}

console.log(binary.join(""));