Explain to me iomanip

Sep 5, 2014 at 10:47pm
Can someone explain to me what this statement does;

cout << fixed << showpoint << setprecision(2);

Sep 5, 2014 at 11:04pm
Sep 8, 2014 at 12:15am
ok that literally did not explain my question at all.

Sep 8, 2014 at 12:34am
The stream manipulator fixed indicates that floating-point values should be
output in so-called fixed-point format, as opposed to scientific notation

showpoint forces the decimal point to appear. e.g
If showpoint is specified without fixed , then trailing zeros will not print

setprecision(x) prints the number with x number of decimal places.

exmple.

1
2
3
4
5
6
7

double test = 2.0;

cout<<fixed<<setprecision(4)<<test;   //ouput: 2
cout<<fixex<<showpoint<<setprecision(2)<<test;   //output:  2.00
cout<<showpoint<<setprecision(2)<<test;     //output: 2
Sep 8, 2014 at 8:30am
ok that literally did not explain my question at all.
If you took the time to read it, you'll find it does; albeit, fixed is not described.
Topic archived. No new replies allowed.