I assume you want to implement rounding with primitives.
To round to four decimal places, multiply with 10e4, convert to integer (effectively truncating or removing the decimals), then divide by float value 10e4 which converts the result back to float again. For example:
#include <stdio.h>
int main()
{
double f = 1.58700023;
printf("%10.10f\n", f);
// Round to 4 decimal places
double r = (int)(f*10000.0)/10000.0;
printf("%10.10f\n", r);
return 0;
}
This outputs:
1.5870002300
1.5870000000
There are many edge cases not supported by this routine, though. E.g., you may want to add one half of 1/10e4 to perform rounding to nearest next digit, etc.