新增负号

main
黄伊雯 1 month ago
parent 6715221fd9
commit ceb77e8794

@ -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();
}

Loading…
Cancel
Save