To print a different text for each float, use the format string "%.*e".
FLT_DECIMAL_DIG - 1- the number of digits required to print each value is floatunambiguous without unjustified accuracy.
#include <float.h>
#include <stdio.h>
fprintf(fPointer, "%.*e", FLT_DECIMAL_DIG - 1, amount);
Usage "%f"will print almost half of small ones float, such as 0.000000001fand -1.2345e-10how 0.000000or -0.000000.
Usage "%f"will print large floatas FLT_MAXwith long text like "340282346638528859811704183484516925440.000000".
source
share