Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Models / CellFormula.cpp
diff options
context:
space:
mode:
1 files changed, 5 insertions, 3 deletions
-rw-r--r--src/Models/CellFormula.cpp8
diff --git a/src/Models/CellFormula.cpp b/src/Models/CellFormula.cpp
index 3cf5bab..69a08f9 100644
--- a/src/Models/CellFormula.cpp
+++ b/src/Models/CellFormula.cpp
@@ -61,11 +61,13 @@ void CellFormula::parseAndSetValue(const char* str) {
currOp = *str;
}
- switch (currOp) {
- case '^': currOp *= -1; break;
+ 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;
}
- formula.add({ptr, currOp});
+ formula.add({ptr, currOp});
}
void CellFormula::readFromFile(std::ifstream& file) {