TAOCP 4.2.4 Exercise 3

Let a normalized positive floating decimal number be written as $10^v \cdot f$, where $v$ is an integer exponent and $f \in [1,10)$ is the fraction part.

Section 4.2.4: Distribution of Floating Point Numbers

Exercise 3. [15] What is the probability that the two leading digits of a floating decimal number are "23", according to the logarithmic law?

Verified: yes
Solve time: 1m49s


Solution

Let a normalized positive floating decimal number be written as $10^v \cdot f$, where $v$ is an integer exponent and $f \in [1,10)$ is the fraction part. By the logarithmic law derived in Section 4.2.4, the probability that the leading digit of $f$ is less than or equal to $d$ is

$$ p(d) = \log_{10} d, \quad 1 \le d \le 9. $$

To determine the probability that the first two digits of $f$ are "23", we condition on the first digit being 2 and the second digit being 3. The fraction part $f$ must satisfy

$$ 23 \le 10^{\log_{10} f} < 24, \quad f \in [1,10). $$

Equivalently, we can write this as

$$ f \in [23/10, 24/10) = [2.3, 2.4). $$

The probability that $f$ lies in this interval is given by the difference of the logarithms at the endpoints:

$$ \Pr(f \in [2.3,2.4)) = \log_{10} 2.4 - \log_{10} 2.3. $$

Computing the difference explicitly, we have

$$ \log_{10} 2.4 - \log_{10} 2.3 = \log_{10} \frac{2.4}{2.3} = \log_{10} \frac{24}{23}. $$

Hence, the probability that the first two digits of a normalized floating decimal number are "23" is

$$ \boxed{\log_{10} \frac{24}{23}}. $$

This completes the solution. ∎