Why is it that in C++, the showpoint
manipulator only has a limit of six significant figures? If anything is beyond six figures, weird things happen. Here's what got me into this question:
int main()
{
double x = 1.345;
cout << showpoint << x << endl;
return 0;
}
Output: 1.34500
Which is totally fine, as expected. However, if I were to do something like this, where I exceed the six significant figure limit, weird things happen with the output:
int main()
{
double x = 1.345678;
cout << showpoint << x << endl;
return 0;
}
Output: 1.34568
Notice that the 7
is missing, and seems to be replaced by 8
. Because by right, our x
is initialized with 1.345678
. So, we should, instead, get 1.345678
, but no. So why is it like that?
Any thoughts?