blob: c1f90f7c981fb53bc95229964291d5d6a3cc082f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#include "CellDouble.h"
#include <cstring>
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 == '-');
if (*str == '-' || *str == '+') str++;
while (*str != '.')
value = value * 10 + ('0' - *(str++));
str++;
for (unsigned div = 10; *str != '\0'; div *= 10)
value += (double)('0' - *(str++)) / div;
if (negative) value *= -1;
}
double CellDouble::getNumeralValue() const {
return value;
}
String CellDouble::getValueForPrint() const {
return String() += value;
}
void CellDouble::parseAndSetValue(const char* str) {
value = atof(str);
}
void CellDouble::writeToFile(std::ofstream& file) {
file << value;
}
|