I have double number in a format like 34.123456789. How can I change it to 34.123?
34.123456789
I just want 3 digits after the decimal point.
You can use:
#include : dbl = round (dbl * 1000.0) / 1000.0;
Just keep in mind that floats and doubles are as close an approximation as the underlying type can provide. It may not be exact.