I have a rounding function,
float myround(float x, int places)
{
float const shift = powf(10.0f, places);
x *= shift;
x = floorf(x + 0.5f);
x /= shift;
return x;
}
When I try to round of numbers to lets say 4 decimal places and then print the number with
printf("%f ", x);
I get the number without rounding. If I print it with
printf("%.4f ", x);
I get the number rounded to 4 places. Should the first printf not print the number to 4 decimal places as I have already rounded the number?
Thanks.