I have a simple C++ program that I thought would print out a double value defined in f and g as doubles ... but C++ is printing them out as integers. I checked the default
There are three floating-point notations:
The default notation just uses the precision value to count all digits of the number, not just the decimal part. If you use a short number (like 3.1415) you can see that the number is displayed correctly.
It's also interesting to know, as cplusplus.com documentation cites, that:
The default notation can be selected by calling str.unsetf(ios_base::floatfield).
P.S.: for C++11 there are new notations: hexfloat for hexadecimal and defaultfloat for the so called (none) before.