blob: 660fc88ed2186cbf0fe2d8cce77de10b3fd87730 (
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
39
|
#include "CellDouble.h"
#include <cstring>
CellDouble::CellDouble(double value) {
this->value = value;
}
/*!
* Accepts a C-style string in the form "<+/-><digits>.<digits>"
*/
CellDouble::CellDouble(const char* str) {
value = 0;
bool negative = *str == '-';
if (*str == '-' || *str == '+') str++;
while (*str != '.')
value = value * 10 + (*(str++) - '0');
str++;
for (unsigned div = 10; *str != '\0'; div *= 10)
value += (double)(*(str++) - '0') / 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;
}
|