Generally we say that a float has precision of 6 digits after the decimal point. But if we store a large number of the order of 10^30 we won’t get 6 digits after the decimal point. So is it correct to say that floats have a precision of 6 digits after the decimal point?
Share
“6 digits after the decimal point” is nonesnse, and your example is a good demonstration of this.
This is an exact specification of the
floatdata type.The precision of the
floatis 24 bits. There are 23 bits denoting the fraction after the binary point, plus there’s also an “implicit leading bit”, according to the online source. This gives 24 significant bits in total.Hence in decimal digits this is approximately:
24 * log(2) / log(10) = 7.22