I used the following to round my values to two decimal places:
x = floor(num*100+0.5)/100;
and it seems to be working fine; except for values such as "16.60", which is "16.6".
I want to display this value as "16.60".
The way to output the values is as follows:
cout setw(12) << round(payment);
I tried the following:
cout setw(12) << setprecision(2) << round(payment);
But it gave me answers like
1.2e+02
How to display values correctly?
source
share