When using cout
, what is the default formatter defined in the <iomanip>
header? In other words, once I've set my formatter to fixed
using cout << fixed << setPrecision(2)
, how do I change it back? Or, what am I changing it back to?
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
- What uses more memory in c++? An 2 ints or 2 funct
相关文章
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
- Converting glm::lookat matrix to quaternion and ba
- What is the correct way to declare and use a FILE
The opposite of
std::fixed
isstd::scientific
.(You find a nice list of manipulators in this great answer.)
The opposite of
std::fixed
isstd::scientific
. That might do for you.However, if you want to restore more flags, or if you need the previous state, instead of the default you can use better solutions:
the
std::resetiosflags
manipulator lets you reset specific flags to their defaults;the two
ios::flags
functions let you save and restore the previous values of the format flags.You can use
resetiosflags()
to unset any flags.The answer is
std::defaultfloat
in C++11. To achieve this in C++03 you can docout.unsetf(std::ios_base::floatfield);
See Really, what's the opposite of "fixed" I/O manipulator?