Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Models / CellDouble.cpp
blob: 675791ea3b5b84d290e6ab1da4d8c25c4b6452a1 (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;
}