Fixed precision question

Hey everyone, I had a question about the proper syntax of using fixed and scientific precision

Specifically on which has to come first.

If I place

cout.setf(ios::fixed) AFTER I say cout.precision(3), will a precision of 3 decimal places output? Or do I have to place the cout.setf(ios::fixed) BEFORE I declare a precision?

Also, how/when is a fixed decimal precision stopped? When I change the precision from lets say cout.precision(3) to cout.precision(14). Do I have to put cout.setf(ios::fixed) between the cout.precision(3) and cout.precision(14), or can I just continue on?
It shouldn't make any difference; the flags should not interfere with each other. (If it does on your compiler, you need to upgrade it.)

Hope this helps.
ok so as long as I have fixed or cout.setf(ios::fixed) somewhere in there it should work?
The effect of setting a format parameter is usually permanent; that is, the parameter setting is in effect until the setting is explicitly changed. The only exception to this rule is the field width. The width is automatically reset to its default value, 0, after each input or output operation that uses the field width.
https://stdcxx.apache.org/doc/stdlibug/28-3.html
Topic archived. No new replies allowed.