1.9: Inexact Numbers
- Page ID
- 96035
Example:
\[\frac{1}{3}=(-1)^{0} \times \frac{1}{4} \times\left(1+\frac{1}{3}\right) \text {, } \nonumber \]
so that \(p=e-127=-2\) and \(e=125=128-3\), or in binary, \(e=01111101\). How is \(f=1 / 3\) represented in binary? To compute binary number, multiply successively by 2 as follows:
\(\begin{array}{lr}0.333 \ldots & 0 . \\ 0.666 \ldots & 0.0 \\ 1.333 \ldots & 0.01 \\ 0.666 \ldots & 0.010 \\ 1.333 \ldots & 0.0101 \\ \text { etc. } & \end{array}\)
so that \(1 / 3\) exactly in binary is \(0.010101 \ldots\) With only 23 bits to represent \(f\), the number is inexact and we have
\[f=01010101010101010101011 \nonumber \]
where we have rounded to the nearest binary number (here, rounded up). The machine number \(1 / 3\) is then represented as
\[00111110101010101010101010101011 \nonumber \]
or in hex
\[\text { Зeaaaaab. } \nonumber \]
Find smallest positive integer that is not exact in single pre- cision
Let \(N\) be the smallest positive integer that is not exact. Now, I claim that
\[N-2=2^{23} \times 1.11 \ldots 1 \nonumber \]
and
\[N-1=2^{24} \times 1.00 \ldots 0 \nonumber \]
The integer \(N\) would then require a one-bit in the \(2^{-24}\) position, which is not available. Therefore, the smallest positive integer that is not exact is \(2^{24}+1=16777217\). In MATLAB, single \(\left(2^{24}\right)\) has the same value as single \(\left(2^{24}+1\right) .\) Since single \(\left(2^{24}+1\right)\) is exactly halfway between the two consecutive machine numbers \(2^{24}\) and \(2^{24}+2\), MATLAB rounds to the number with a final zero-bit in \(f\), which is \(2^{24} .\)