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
This question is tagged C++, so I'll proceed under that assumption. Note that the C++ streams will round, unlike the C printf family. All you have to do is provide the precision you want and the streams library will round for you. I'm just throwing that out there in case you don't already have a reason not to use streams.