0
What is better?
1 2 3 4 5 6 #include <iomanip.h> . . . . cout<<setprecision(2)<<myFloat; or #include <math.h> . . . . myFloat=floor(myFloat*100)/100;
1 Respuesta
+ 4
To say which way is better requires knowing more about the requirements.
The first technique is better if you need to keep the original value in myFloat.
The second technique is better if you no longer need the original value in myFloat and the truncated value will be useful thereafter.