P > X so style=f and precision=0.
I guess this means it should print the same as printf("%.0f", 0.00001) but it doesn't. If I instead change to printf("%.0e\n", 0.00001) it looks the same. Did I make a mistake somewhere?
All this becomes very technical. I was hoping there was a simpler explanation that explains what all these rules are trying to accomplish.
Is it somewhat correct to say that it uses scientific notation if it gives a shorter output or a more precise answer, using at most as many digits as specified by the precision, not counting digits in the exponent?
Ah, OK, thank you, so it becomes printf("%.5e\n", 0.00001) which prints 1.00000e-05. This is still wrong but hold on ...
Right after the text you quoted about %g it says the following.
Unless alternative representation is requested the trailing zeros are removed, also the decimal point character is removed if no fractional part is left. For infinity and not-a-number conversion style see notes.