I\'m using the following code for rounding to 2dp:
sprintf(temp,\"%.2f\",coef[i]); //coef[i] returns a double
It successfully rounds 6.666
You could also do this (saves multiply/divide):
printf("%.2f\n", coef[i] + 0.00049999);