Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the opposite of `fixed` in cout?

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?

like image 781
Moshe Avatar asked Sep 14 '11 19:09

Moshe


2 Answers

The answer is std::defaultfloat in C++11. To achieve this in C++03 you can do

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

See Really, what's the opposite of "fixed" I/O manipulator?

like image 69
rmp251 Avatar answered Oct 15 '22 00:10

rmp251


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

(You find a nice list of manipulators in this great answer.)

like image 29
sbi Avatar answered Oct 14 '22 23:10

sbi