I'm testing the significant digit lengths for float and double in Visual Studio's C++ compiler and it's only showing 6 significant digits for float, double, and long double even though C++ Primer describes float as showing 6 significant digits and double/long double as 10. Why is this the case?
Here's the code using random numbers:
#include <iostream>
int main()
{
float dec=12.789346;
long double dec2=12.98746359;
std::cout << dec << std::endl
<< dec2 << std::endl;
std::cin.get();
std::cin.get();
return 0;
}
My output is
12.7893
12.9875