I need to show that a single precision format, which contains 24 total bits of precision, is equivalent to about 7 decimal digits of precision.
The expression I found was simply log10(224) = 7.225, which yields the expected results of 7 digits of precision, however, I can't find a formula proof of this expression or intuition on how it works
For common
float:Between [1.0... 2.0) there are 223 different
float- evenly spaced.Between [2.0... 4.0) there are 223 different
float- evenly spaced.Between [4.0... 8.0) there are 223 different
float- evenly spaced.Between [8.0...10.0) there are 1/4 * 223 different
float- evenly spaced.Between [4.0... 8.0) there are 1/2 223 different
floatspaced as far apart as those in [8.0...10.0).Between [2.0... 4.0) there are 1/4 223 different
floatspaced as far apart as those in [8.0...10.0).Between [1.0... 2.0) there are 1/8 223 different
floatspaced as far apart as those in [8.0...10.0).Between [1.0...10.0) there are 9/8 223 different
floatspaced as far apart as those in [8.0...10.0) or 9,437,184.Between [1.0...10.0) there are 9,000,000 different 7-decimal digit values space 0.000 001 apart.
Since we have 9,437,184 evenly spaced
floatto encode more than 9,000,000 different values, we can claim "about 7 decimal digits of precision".Different decade ranges will result in similar "about 7 decimal digits".
IIRC, the worst case decade is just a tad less than "7 decimal digits of precision" (about 6.92), perhaps in the range [1,000,000...10,000,000).
OP's log10(224) = 7.225 is a good first step. Yet
floatvalues are distributed linearly per powers of 2. To compare with decimal precision, we want to see the distribution among various powers of 10.The C spec has
FLT_DIG*1 for binaryfloatas below which is close to OP's goal.*1
FLT_DIGnumber of decimal digits, q, such that any floating-point number with q decimal digits can be rounded into a floating-point number with p radix b digits and back again without change to the q decimal digits