blob: a2a624d0d11b3f1d3c4a3b57647f83c5e244451b (
plain)
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
|
#include "conversion.hpp"
UniquePtr<SmartString> doubleToStr(double num, unsigned int width, unsigned int precision)
{
auto str = make_unique<SmartString>(width + precision);
dtostrf(num, static_cast<signed char>(width), precision, str->c_str);
return str;
}
UniquePtr<SmartString> intToStr(int num)
{
auto width = static_cast<unsigned int>(log10(num));
auto str = make_unique<SmartString>(width + 1U);
dtostrf(num, static_cast<signed char>(width + 1U), 0, str->c_str);
return str;
}
UniquePtr<SmartString> uintToStr(unsigned int num)
{
auto width = static_cast<unsigned int>(log10(num));
auto str = make_unique<SmartString>(width + 1U);
dtostrf(num, static_cast<signed char>(width + 1U), 0, str->c_str);
return str;
}
|