Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Models / CellFormula.cpp
diff options
context:
space:
mode:
Commitf5cfef9dc1c0cc505d48c609a1c0511cd7ed166b (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-05-28 16:44:11 +0300
Committer
 Syndamia <kamen@syndamia.com>
2022-05-28 16:44:11 +0300
Filesadba3eb02741f5a0f243c1993a1deef626308bd2 /src/Models/CellFormula.cpp
FMI-OOP-P2_Tables-f5cfef9dc1c0cc505d48c609a1c0511cd7ed166b.tar
FMI-OOP-P2_Tables-f5cfef9dc1c0cc505d48c609a1c0511cd7ed166b.tar.gz
FMI-OOP-P2_Tables-f5cfef9dc1c0cc505d48c609a1c0511cd7ed166b.zip
Parent827f0a8227b7db8ddf3f7ec0fa39bb945ea13bdb (diff)
Autocommit at 28.05.2022 @ 16:44
1 files changed, 4 insertions, 7 deletions
-rw-r--r--src/Models/CellFormula.cpp11
diff --git a/src/Models/CellFormula.cpp b/src/Models/CellFormula.cpp
index 1f5b766..71e4e29 100644
--- a/src/Models/CellFormula.cpp
+++ b/src/Models/CellFormula.cpp
@@ -3,26 +3,23 @@
#include <cstring>
double CellFormula::calculate(unsigned index) {
- double lval = CellDouble(formula[index].left->getValue()).getValue();
+ double lval = CellDouble(formula[index].left->getValue()).getNumeralValue();
switch(formula[index].right) {
case plus: return lval + calculate(index++);
case minus: return lval - calculate(index++);
case mult: return lval * calculate(index++);
- case div: double rval = calculate(index++);
- if (rval == 0) throw std::overflow_error("Divide by zero exception");
- return lval / rval;
+ case div: return lval / calculate(index++);
default: return lval;
}
}
String CellFormula::getValueForPrint() {
- double result = calculate();
-
- return "";
+ return String() += calculate();
}
void CellFormula::parseAndSetValue(const char* str) {
+ //TODO
}
void CellFormula::readFromFile(std::ifstream& file) {