I can set precision of cout
output using
cout.precision(precision_value);
how can I get the precision value, which is used by cout
already?
I can't find any other related function in cout
description.
The related problem I faced is how can I change cout precision for some part of a code only (so it need to be reset afterwards to exact previous value).
I tryed:
//save original cout flags
std::ios_base::fmtflags coutFlags = cout.flags();
cout.precision(1);
cout.setf(ios::fixed);
// code
cout.flags(coutFlags);
but this doens't work.
cout.setf(ios::fixed);
overwrites all flags, and not just the flag of interest. I made the same mistake recently: istringstream not honoring base?. – Shull