1.9: Inexact Numbers
- Page ID
- 96035
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
\( \newcommand{\dsum}{\displaystyle\sum\limits} \)
\( \newcommand{\dint}{\displaystyle\int\limits} \)
\( \newcommand{\dlim}{\displaystyle\lim\limits} \)
\( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)
( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)
\( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)
\( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)
\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)
\( \newcommand{\Span}{\mathrm{span}}\)
\( \newcommand{\id}{\mathrm{id}}\)
\( \newcommand{\Span}{\mathrm{span}}\)
\( \newcommand{\kernel}{\mathrm{null}\,}\)
\( \newcommand{\range}{\mathrm{range}\,}\)
\( \newcommand{\RealPart}{\mathrm{Re}}\)
\( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)
\( \newcommand{\Argument}{\mathrm{Arg}}\)
\( \newcommand{\norm}[1]{\| #1 \|}\)
\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)
\( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)
\( \newcommand{\vectorA}[1]{\vec{#1}} % arrow\)
\( \newcommand{\vectorAt}[1]{\vec{\text{#1}}} % arrow\)
\( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vectorC}[1]{\textbf{#1}} \)
\( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)
\( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)
\( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\(\newcommand{\longvect}{\overrightarrow}\)
\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
\(\newcommand{\ket}[1]{\left| #1 \right>}\)
\(\newcommand{\bra}[1]{\left< #1 \right|}\)
\(\newcommand{\braket}[2]{\left< #1 \vphantom{#2} \right| \left. #2 \vphantom{#1} \right>}\)
\(\newcommand{\braopket}[3]{\left< #1 \vphantom{#2}\vphantom{#3} \right| #2 \vphantom{#1}\vphantom{#3} \left| #3 \vphantom{#1}\vphantom{#2} \right>}\)
\(\newcommand{\qmvec}[1]{\mathbf{\vec{#1}}}\)
\(\newcommand{\op}[1]{\hat{\mathbf{#1}}}\)
\(\newcommand{\expect}[1]{\langle #1 \rangle}\)
\(\newcommand{\dfn}[1]{\emph{\textbf{#1}}}\)
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} .\)


