From 1bbfed319336bf6002e4bc47c11c0260386320b9 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 29 May 2022 14:45:12 +0300 Subject: Autocommit at 29.05.2022 @ 14:45 --- src/Models/CellFormula.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src/Models/CellFormula.cpp') diff --git a/src/Models/CellFormula.cpp b/src/Models/CellFormula.cpp index 942b6e5..2e2636d 100644 --- a/src/Models/CellFormula.cpp +++ b/src/Models/CellFormula.cpp @@ -80,12 +80,8 @@ void CellFormula::parseAndSetValue(const char* str) { if (currOp == '^') currOp *= -1; else if ((currOp == '+' || currOp == '-') && formula.get_count() != 0) { - unsigned cntr = 1; - Pair& prev = formula[formula.get_count() - cntr]; - while (prev.right == '*' || prev.right == '/') { - prev.right *= -1; - prev = formula[formula.get_count() - ++cntr]; - } + for (unsigned i = formula.get_count() - 1; (formula[i].right == '*' || formula[i].right == '/') && i > 0; i--) + if (formula[i].right > 0) formula[i].right *= -1; } if (currOp == '-') { -- cgit v1.3.1-23-gd82d