What is the difference between ios::base:precision & setprecision Given in the following links? http://www.cplusplus.com/reference/ios/ios_base/precision/
http://www.cplusplus.com/reference/iomanip/setprecision/
The difference it to do with the usage. The first (setter) is a member function, so gets called like this:
std::cout.precision(10);
The second isn't a member function so is called different.
std::cout << std::setprecision(10);
The 2nd link explicitly says
"Behaves as if member precision were called with n as argument on the stream on which it is inserted/extracted as a manipulator "
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With