+ 2
What is the purpose of fixed in cout << fixed
3 Respostas
+ 5
fixed is basically used with setprecision function
fixed counts the no of digits after decimal point and prevents its rounding off
for eg , f = 1.2348
cout<<setprecision(4)<<f will give the ouput 1.235
but cout<<fixed;
cout<<setprecision (4)<<f will give the output 1.2348
+ 8
C++ Reference:
http://www.cplusplus.com/reference/ios/fixed/
+ 2
also , when floatfield is set to fixed , it repesents float values using fixed point notation
for eg
float a=10.0
cout<<setprecision (5);
cout<<fixed<<a; will give the output 10.00000