Explain to me iomanip
Can someone explain to me what this statement does;
cout << fixed << showpoint << setprecision(2);
ok that literally did not explain my question at all.
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
|
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.