header? In other words, once I set m...">

What is the opposite of "fixed" in cout?

When using cout , what is the default format defined in the <iomanip> header? In other words, once I set my fixed formatter using cout << fixed << setPrecision(2) , how do I change it? Or that I change it back?

+6
source share
4 answers

The opposite of std::fixed is equal to std::scientific .

(You will find a good list of manipulators in this excellent answer .)

+4
source

Answer: std::defaultfloat in C ++ 11. For this in C ++ 03 you can do

cout.unsetf(std::ios_base::floatfield);

See Really, what is the opposite of โ€œfixedโ€? I / O manipulator?

+3
source

You can use resetiosflags() to cancel any flags.

+1
source

The opposite of std::fixed is equal to std::scientific . It can do for you.

However, if you want to restore more flags or if you need a previous state, instead of the default, you can use the best solutions:

  • the std::resetiosflags allows you to reset certain flags by default;

  • two ios::flags functions allow you to save and restore the previous values โ€‹โ€‹of format flags.

+1
source

Source: https://habr.com/ru/post/897343/


All Articles