I have the following decimal number converter
function binario(numero) {
var division = 0;
var binario = [];
do {
division = numero / 2;
if (numero % 2 == 0) {
binario.unshift("1");
} else {
binario.unshift("0");
}
numero = Math.round(division);
} while (numero > 1);
binariof = binario.join("");
alert(binariof);
}
binario(28);
The problem: the conversion returns me wrong, in this case 28 would be 11100 and returns 11011.
What am I doing wrong?