// 将十进制转换为二进制 functionconversionSystem (number, system) { system = system ? system : 2; var stack = newStack(); var rem, binary = ''; while (number > 0) { rem = Math.floor(number % system); stack.push(rem); number = Math.floor(number / system); }
while (!stack.isEmpty()) { binary += String(stack.pop()); } return binary; }