diff options
Autocommit at 29.05.2022 @ 14:40
1 files changed, 7 insertions, 3 deletions
| -rw-r--r-- | src/Models/CellFormula.cpp | 10 |
diff --git a/src/Models/CellFormula.cpp b/src/Models/CellFormula.cpp index 6aaeefd..942b6e5 100644 --- a/src/Models/CellFormula.cpp +++ b/src/Models/CellFormula.cpp @@ -71,7 +71,7 @@ void CellFormula::parseAndSetValue(const char* str) { } else { double val = atof(str); - while ((*str >= '0' && *str <= '9') || *str == ' ') str++; + while ((*str >= '0' && *str <= '9') || *str == ' ' || *str == '.') str++; currOp = *str; localCells.add(CellDouble(val)); @@ -80,8 +80,12 @@ void CellFormula::parseAndSetValue(const char* str) { if (currOp == '^') currOp *= -1; else if ((currOp == '+' || currOp == '-') && formula.get_count() != 0) { - Pair<Cell*, char>& prev = formula[formula.get_count() - 1]; - if (prev.right == '*' || prev.right == '/') prev.right *= -1; + unsigned cntr = 1; + Pair<Cell*, char>& prev = formula[formula.get_count() - cntr]; + while (prev.right == '*' || prev.right == '/') { + prev.right *= -1; + prev = formula[formula.get_count() - ++cntr]; + } } if (currOp == '-') { |
