Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Models / CellFormula.cpp
diff options
context:
space:
mode:
Commit657f9b35f4469f301cb458f423352edc53281743 (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-05-29 14:40:10 +0300
Committer
 Syndamia <kamen@syndamia.com>
2022-05-29 14:40:10 +0300
Files7cd49f3d84d2e54f587c908101772cd282e7b265 /src/Models/CellFormula.cpp
FMI-OOP-P2_Tables-657f9b35f4469f301cb458f423352edc53281743.tar
FMI-OOP-P2_Tables-657f9b35f4469f301cb458f423352edc53281743.tar.gz
FMI-OOP-P2_Tables-657f9b35f4469f301cb458f423352edc53281743.zip
Parente8f80d969c9280fbb13a9f8a62391e9f211f7786 (diff)
Autocommit at 29.05.2022 @ 14:40
1 files changed, 7 insertions, 3 deletions
-rw-r--r--src/Models/CellFormula.cpp10
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 == '-') {