I have a double variable, the contents of which need to be converted into a string. I need to calculate, how long that string would end up being, so I tried using size(), but that leads to unexpected results.
From this:
double test_double;
test_double = 12.34;
std::wstring test_string = L"12.34";
std::wcout << L"string is: " << test_string << std::endl;
std::wcout << L"length of string is: " << test_string.size() << std::endl; //this shows expected result
std::wcout << L"double is: " << test_double << std::endl;
std::wcout << L"length of double is: " << (std::to_wstring(test_double)).size() << std::endl; //and this makes me wonder
I get this output:
string is: 12.34
length of string is: 5
double is: 12.34
length of double is: 9
The strings seem to end up being identical, but the result of a conversion is different for some reason. Am I missing something?