js将正整数转化为二进制
//正整数转化为二进制 function divideBy2(decNumber) { var decStack = []; var rem; var decString = ''; while (decNumber > 0) { rem = decNumber % 2; decStack.push(rem); decNumber = Math.floor(decNumber / 2); } while (decStack.length != 0) { decString += decStack.pop().toString(); } return decString; } console.log(divideBy2(10)); //1010