diff options
Autocommit at 14.06.2022 @ 09:03
3 files changed, 6 insertions, 8 deletions
| -rw-r--r-- | src/Models/CellDouble.cpp | 8 | ||||
| -rw-r--r-- | src/Models/CellFormula.cpp | 4 | ||||
| -rw-r--r-- | src/Models/CellInt.cpp | 2 |
diff --git a/src/Models/CellDouble.cpp b/src/Models/CellDouble.cpp index c1f90f7..538bf11 100644 --- a/src/Models/CellDouble.cpp +++ b/src/Models/CellDouble.cpp @@ -5,18 +5,16 @@ CellDouble::CellDouble(double value) { this->value = value; } -#include <iostream> CellDouble::CellDouble(const char* str) { - std::cout << "Double: " << str << std::endl; value = 0; - bool negative = (*str == '-'); + bool negative = *str == '-'; if (*str == '-' || *str == '+') str++; while (*str != '.') - value = value * 10 + ('0' - *(str++)); + value = value * 10 + (*(str++) - '0'); str++; for (unsigned div = 10; *str != '\0'; div *= 10) - value += (double)('0' - *(str++)) / div; + value += (double)(*(str++) - '0') / div; if (negative) value *= -1; } diff --git a/src/Models/CellFormula.cpp b/src/Models/CellFormula.cpp index d5aea00..5146bce 100644 --- a/src/Models/CellFormula.cpp +++ b/src/Models/CellFormula.cpp @@ -8,8 +8,8 @@ const Cell* CellFormula::ptrByInd(Pair<int, int> loc) const { return (loc.left < 0) ? &localCells[loc.right] : (*tableCells)[loc.left][loc.right]; } -double pow(double x, unsigned y) { - if (y == 0) return 1; +double pow(double x, int y) { + if (y <= 0) return 1; double res = x; for (unsigned i = 1; i < y; i++) diff --git a/src/Models/CellInt.cpp b/src/Models/CellInt.cpp index 37283e4..2e61099 100644 --- a/src/Models/CellInt.cpp +++ b/src/Models/CellInt.cpp @@ -13,7 +13,7 @@ CellInt::CellInt(const char* str) { if (*str == '-' || *str == '+') str++; while (*str != '\0') - value = value * 10 + '0' - *(str++); + value = value * 10 + (*(str++) - '0'); if (negative) value *= -1; } |
