J
john smith
Hi, I would like to save a stream's output precision and then change the
precision and then restore it. One example I found was using
ios_base::fixed, and ios_base::floatfield. But on my machine this only
gives 6 or 8 digits after the decimal. I would like at least 12. If I do
cout.precision(12), then cout is forever set to 12 precisions from that
point on. I guess I can call cout.precision(4) when I'm done, but how do I
know that 4 is the default?
example:
ios_base::fmtflags f = cout.flags();
cout.setf(ios_base::fixed, ios_base::floatfield);
cout << 12.5123123123123123123123123123 << endl;
cout.flags(f);
cout << 12.5123123123123123123123123123 << endl;
Thanks in advance.
precision and then restore it. One example I found was using
ios_base::fixed, and ios_base::floatfield. But on my machine this only
gives 6 or 8 digits after the decimal. I would like at least 12. If I do
cout.precision(12), then cout is forever set to 12 precisions from that
point on. I guess I can call cout.precision(4) when I'm done, but how do I
know that 4 is the default?
example:
ios_base::fmtflags f = cout.flags();
cout.setf(ios_base::fixed, ios_base::floatfield);
cout << 12.5123123123123123123123123123 << endl;
cout.flags(f);
cout << 12.5123123123123123123123123123 << endl;
Thanks in advance.