From a71bf80a04f811ca84f6610c48b20497c0e9d29f Mon Sep 17 00:00:00 2001 From: olzhasus Date: Wed, 3 Jun 2026 16:36:53 +0000 Subject: [PATCH] =?UTF-8?q?calc:=20=D1=82=D0=BE=D0=BB=D1=8C=D0=BA=D0=BE=20?= =?UTF-8?q?=D1=81=D0=BB=D0=BE=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B8=20?= =?UTF-8?q?=D0=B2=D1=8B=D1=87=D0=B8=D1=82=D0=B0=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/index.html b/index.html index 0936e23..aa5cf71 100644 --- a/index.html +++ b/index.html @@ -97,25 +97,20 @@ body {
0
- - - - - - + - + - + @@ -149,8 +144,6 @@ document.querySelectorAll('[data-num]').forEach(btn => { document.querySelectorAll('[data-op]').forEach(btn => { btn.addEventListener('click', () => { const op = btn.dataset.op; - if (op === '±') { current = String(parseFloat(current) * -1); updateDisplay(current); return; } - if (op === '%') { current = String(parseFloat(current) / 100); updateDisplay(current); return; } if (previous !== '' && !resetDisplay) compute(); previous = current; operation = op; @@ -179,14 +172,10 @@ function compute() { const b = parseFloat(current); if (isNaN(a) || isNaN(b)) return; let result; - switch (operation) { - case '+': result = a + b; break; - case '−': result = a - b; break; - case '×': result = a * b; break; - case '÷': result = b !== 0 ? a / b : 'Ошибка'; break; - default: return; - } - current = typeof result === 'number' ? String(Math.round(result * 1e10) / 1e10) : result; + if (operation === '+') result = a + b; + else if (operation === '−') result = a - b; + else return; + current = String(Math.round(result * 1e10) / 1e10); updateDisplay(current); resetDisplay = true; }