A quick little
C function that
rounds off
floating point values to a specified number of
digits after the
decimal point. This assumes you're treating your values as
decimal values:
#include
double round(double number, int nplaces)
{
double dec = pow(10, nplaces);
return ((int)(number*dec + 0.5))/dec;
}