The following snippet outputs 0.29847 when I would have expected 0.29848:

double f = 0.298475;
cout << setprecision(5) << f << endl;

For other examples, however, I observe rounding:

double f = 0.123459;
cout << setprecision(5) << f << endl;

outputs: 0.12346

and

double f = 0.123454;
cout << setprecision(5) << f << endl;

outputs: 0.12345

Edit
Report