"... The indicator always contains at least two digits and only as many digits as necessary to represent the exhibitor ...." C11dr ยง7.21.6.1 8
So 3.45e+07 is compatible (which the OP does not want), and 3.45e+007 incompatible (what the OP wants).
Since C does not provide a standard way for the code to change the number of digits of the exponent, the code is reserved for itself.
Various compilers support some control.
visual studio _set_output_format
For fun, the following DIY code
double x = 34523423.52342353; // - 1 . xxx e - EEEE \0 #define ExpectedSize (1+1+1 +3 +1+1+ 4 + 1) char buf[ExpectedSize + 10]; snprintf(buf, sizeof buf, "%.3e", x); char *e = strchr(buf, 'e'); // lucky 'e' not in "Infinity" nor "NaN" if (e) { e++; int expo = atoi(e); snprintf(e, sizeof buf - (e - buf), "%05d", expo); // 5 more illustrative than 3 } puts(buf); 3.452e00007
Also see C ++ on how to get "one exponent" with printf
chux
source share