The C standard says that for the f
and F
floating point format specifiers:
If a decimal-point character appears, at least one digit appears before it.
I think that if you don't want a zero to appear before the decimal point, you'll probably have to do something like use snprintf()
to format the number into a string, and remove the 0
if the formatted string starts with "0." (and similarly for "-0."). Then pass that formatted string to our real output. Or something like that.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…