I keep stumbling on the format specifiers for the printf() family of functions. What I want is to be able to print a double (or float) with a maximum given number of digits
Why not just do this?
double f = 359.01335; printf("%g", round(f * 1000.0) / 1000.0);