Printf width specifier to maintain precision of floating-point value

I recommend @Jens Gustedt hexadecimal solution: use %a. OP wants “print with maximum precision (or at least to the most significant decimal)”. A simple example would be to print one seventh as in: #include <float.h> int Digs = DECIMAL_DIG; double OneSeventh = 1.0/7.0; printf(“%.*e\n”, Digs, OneSeventh); // 1.428571428571428492127e-01 But let’s dig deeper … Mathematically, the … Read more