Possible Duplicate:
Rounding Number to 2 Decimal Places in C
I have not found a function with a signature double round(double d, int digits) like here in c.
When i try to build i get a error:
error: too many arguments to function ’round’
How can I round in C with N digits after the decimal point?
Using recursion (which is going to be slow for some values of digits)
A method likely to be somewhat faster, but which relies on a single call to the slow
powfunction:An even faster method is to precompute a lookup table with the likely powers and use that instead of
pow.