Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Models / CellDouble.cpp
blob: e19be3b1fe61882cb27105ecb4c3a006c9e31990 (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
#include "CellDouble.h"
#include <cstring>

CellDouble::CellDouble(double value) {
	this->value = value;
}

CellDouble::CellDouble(const char* str) {
	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;
}