I like to change the number of decimal digits showed whenever I use a float number in C. Does it have something to do with the FLT_DIG
value defined in float.h
? If so, how could I change that from 6 to 10?
I'm getting a number like 0.000000
while the actual value is 0.0000003455
.
There are two separate issues here: The precision of the floating point number stored, which is determined by using float
vs double
and then there's the precision of the number being printed as such:
float foo = 0.0123456789;
printf("%.4f\n", foo); // This will print 0.0123 (4 digits).
double bar = 0.012345678912345;
printf("%.10lf\n", bar); // This will print 0.0123456789
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With