For example in this table they say 7 digits to float, and 15 digits to double: https://docs.microsoft.com/en-us/cpp/cpp/data-type-ranges
But this statement returns 9:
std::cout << std::numeric_limits<float>::max_digits10 << '\n';
Add this returns 17:
std::cout << std::numeric_limits<double>::max_digits10 << '\n';
Maybe we should substract the + or the - sign, and the dot from the number of digits? Here they say that this precision is guaranteed digits remain after text -> number -> text conversion: https://en.cppreference.com/w/cpp/types/numeric_limits/max_digits10
But when i do this, the precision is always 7, in the case of double also:
#include <iostream>
#include <string>
int main() {
double d_example = 0.123456789;
std::string str_example = std::to_string(d_example);
d_example = stod(str_example);
std::cout << str_example << '\n';
std::cout << d_example << '\n';
}