|
|
|
@ -82,6 +82,7 @@
|
|
|
|
|
<button onclick="compute()">=</button>
|
|
|
|
|
<button onclick="chooseOperation('+')">+</button>
|
|
|
|
|
<button onclick="chooseOperation('%')">%</button>
|
|
|
|
|
<button onclick="appendNumber('-')">±</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
@ -94,6 +95,7 @@
|
|
|
|
|
|
|
|
|
|
function appendNumber(number) {
|
|
|
|
|
if (number === '.' && currentOperand.includes('.')) return;
|
|
|
|
|
if (number === '-' && currentOperand.length > 0) return; // 防止在数字中间添加负号
|
|
|
|
|
currentOperand += number;
|
|
|
|
|
updateDisplay();
|
|
|
|
|
}
|
|
|
|
@ -150,4 +152,4 @@
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|
|
|
|
|
</html>
|
|
|
|
|