display | more...
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:


double round(double number, int nplaces)
    double dec = pow(10, nplaces);
    return ((int)(number*dec + 0.5))/dec;

Log in or register to write something here or to contact authors.