If you want the same format the "%f"
specifier uses (rather than the default which is "%g"
), you'd use
std::cout << std::fixed;
To restore the original format, i.e., get back to using the same format as "%g"
you'd use
std::cout << std::defaultfloat; // C++11
std::cout.setf(std::ios_base::fmtflags(), std::ios_base::floatfield); // pre C++11