EXERCISES 0.3

\(\def\oneth{\frac{1}{3}} \def\oneh{\frac{1}{2}} \def\oneq{\frac{1}{4}} \def\twoth{\frac{2}{3}} \) 1 (a) \((\oneq)_{10} = (0.01)_2\); fl\((\oneq) = +1.0\times 2^{-2}\).

1 (b) \((\oneth)_{10} = (0.\overline{01})_2 =\)

\(+1.\ \fbox{0101010101010101010101010101010101010101010101010101}\ 0101\ldots \times 2^{-2}\).

The Rounding to Nearest Rule says to round down when the \(53\)rd bit is \(0\).

fl\((\oneth) = +1.\ \fbox{0101010101010101010101010101010101010101010101010101}\times 2^{-2}\).

1 (c) \((\twoth)_{10} = (0.\overline{10})_2 =\)

\(+1.\fbox{0101010101010101010101010101010101010101010101010101}\ 0101\ldots \times 2^{-1}\).

fl\((\twoth) = +1.\ \fbox{0101010101010101010101010101010101010101010101010101}\times 2^{-1}\).

1 (d) \((0.9)_{10} = (0.1\overline{1100})_2 =\)

\(+1.\ \fbox{1100110011001100110011001100110011001100110011001100}\ 1100\ldots \times 2^{-1}\).

The Rounding to Nearest Rule says to round up since the \(53\)rd bit is nonzero, and further bits are nonzero.

fl\((0.9) = +1.\ \fbox{1100110011001100110011001100110011001100110011001101}\times 2^{-1}\).


3 Note that fl\((5)=1.01\times 2^{2}\). Adding \(1\) as bit \(3, 4, \ldots, 52\) of the mantissa will not incur rounding error. These correspond to \(2^{-k}\) for \(k=1, 2, \ldots, 50\).
5 (a) \(1+(2^{-51}+2^{-53}) = \)

\(+1.\ \fbox{0000000000000000000000000000000000000000000000000010}\ 1 \times 2^{0}\).

fl\((1+(2^{-51}+2^{-53})) =\)

\(+1.\ \fbox{0000000000000000000000000000000000000000000000000010} \times 2^{0},\) using the Rounding to Nearest Rule. Therefore fl\(((1+(2^{-51}+2^{-53}))-1) = \)

\(.\ \fbox{0000000000000000000000000000000000000000000000000010}\)

\( = 1.\ \fbox{0000000000000000000000000000000000000000000000000000}\times 2^{-51} = 2^{-51}\).

5 (b) \(1+(2^{-51}+2^{-52}+2^{-53}) = \)

\(+1.\ \fbox{0000000000000000000000000000000000000000000000000011}\ 1 \times 2^{0}\).

fl\((1+(2^{-51}+2^{-52}+2^{-53})) =\)

\(+1.\ \fbox{0000000000000000000000000000000000000000000000000100} \times 2^{0},\) using the Rounding to Nearest Rule. Therefore fl\(((1+(2^{-51}+2^{-52}+2^{-53}))-1) = \)

\(.\ \fbox{0000000000000000000000000000000000000000000000000100}\)

\( = 1.\ \fbox{0000000000000000000000000000000000000000000000000000}\times 2^{-50}=2^{-50}\).


7 (a) \((8)_{10} = (1000.)_2 = 1.0\times 2^3\). The hex representation is 0x1.0000000000000p+3.

7 (b) \((21)_{10} = (10101.)_2 = 1.0101\times 2^4\). The hex representation is 0x1.5000000000000p+4.

7 (c) \((1/8)_{10} = 1.0\times 2^{-3}\). The hex representation is 0x1.0000000000000p-3.

7 (d) \((1/3)_{10} = 1.\overline{01}\times 2^{-2}\), and after rounding down, fl\((1/3)=1.0101\ldots 0101\times 2^{-2}\). The hex representation is 0x1.5555555555555p-2.

7 (e) \((2/3)_{10} = 1.\overline{01}\times 2^{-1}\), and after rounding down, fl\((2/3)=1.0101\ldots 0101\times 2^{-1}\). The hex representation is 0x1.5555555555555p-1.

7 (f) \((0.1)_{10} = 1.\overline{1001}\times 2^{-4}\), and after rounding up, fl\((0.1)=1.1001\ldots 1001\) \(1010\times 2^{-4}\). The hex representation is 0x1.999999999999Ap-4.

7 (g) \((-0.1)_{10} = -1.\overline{1001}\times 2^{-4}\), and after rounding, fl\((-0.1)=-1.1001\ldots 1001\) \(1010\times 2^{-4}\). The hex representation is -0x1.999999999999Ap-4.

7 (h) \((-0.2)_{10} = -1.\overline{1001}\times 2^{-3}\), and after rounding, fl\((-0.2)=-1.1001\ldots 1001\) \(1010\times 2^{-3}\). The hex representation is -0x1.999999999999Ap-3.


9 (a) \((7/3)_{10} = 1.00\overline{10}\times 2^{1}\), and after rounding, fl\((7/3)=1.0010\ldots 1010\ 1011\times 2^{1}\).

\((4/3)_{10} = 1.\overline{01}\times 2^{0}\), and after rounding, fl\((4/3)=1.01\ldots 0101\ 0101\times 2^{0}\). Subtracting gives \begin{eqnarray*} && 1.\fbox{0010101010101010101010101010101010101010101010101011}0 \times 2^1\\ &-& 0.\fbox{1010101010101010101010101010101010101010101010101010}1 \times 2^1 \nonumber\\ &=& 0.\fbox{1000000000000000000000000000000000000000000000000000}1 \times 2^1 \end{eqnarray*} that is normalized to \begin{eqnarray*} && 1.\fbox{0000000000000000000000000000000000000000000000000001} \times 2^0, \end{eqnarray*} which is \(1+\epsilon_\text{mach}\). After subtracting \(1\), the result is that the double precision floating point version of \((7/3-4/3)-1\) is \(\epsilon_\text{mach}\).

9 (b) \((4/3)_{10} = 1.\overline{01}\times 2^{0}\), and after rounding, fl\((4/3)=1.01\ldots 0101\ 0101\times 2^{0}\). \((1/3)_{10} = 1.\overline{01}\times 2^{-2}\), and after rounding, fl\((1/3)=1.01\ldots 0101\ 0101\times 2^{-2}\). Subtracting gives \begin{eqnarray*} && 1.\fbox{0101010101010101010101010101010101010101010101010101}00 \times 2^0\\ &-& 0.\fbox{0101010101010101010101010101010101010101010101010101}01 \times 2^0 \nonumber\\ &=& 0.\fbox{1111111111111111111111111111111111111111111111111111}11 \times 2^0 \end{eqnarray*} that normalizes to \begin{eqnarray*} && 1.\fbox{1111111111111111111111111111111111111111111111111111}1 \times 2^{-1} \end{eqnarray*} and rounds to \begin{eqnarray*} && 10.\fbox{0000000000000000000000000000000000000000000000000000} \times 2^{-1} \end{eqnarray*} which is \(1.0\times 2^{0}\). After subtracting \(1\), the result is machine zero, not \(\epsilon_\text{mach}\).


11 The associative law of addition fails for floating point addition with the Rounding to Nearest Rule, for example, because \(1+(\epsilon_\text{mach}/2+\epsilon_\text{mach}/2) = 1+\epsilon_\text{mach}>1\), while \((1+\epsilon_\text{mach}/2)+ \epsilon_\text{mach}/2 =1\), because \(1+\epsilon_\text{mach}/2=1\).
13. (c) In double precision floating point, \(1 - (2^{-54}+2^{-106}) < 1\).
15(a) \((8.3)_{10} = 1.0000\overline{1001}\times 2^{3}\), and rounded, fl\((8.3)=1.0000\ 1001\ 1001\ldots 1001\ 1010\times 2^{3}\). \((7.3)_{10} = 1.110\overline{1001}\times 2^{2}\), and rounded, fl\((7.3)=1.1101\ 0011\ 0011\ldots 0011\ 0011\times 2^{2}\). Subtracting gives \begin{eqnarray*} && 1.\fbox{0000100110011001100110011001100110011001100110011010}\ 0 \times 2^3\\ &-& 0.\fbox{1110100110011001100110011001100110011001100110011001}\ 1 \times 2^3 \nonumber\\ &=& 0.\fbox{0010000000000000000000000000000000000000000000000000}\ 1 \times 2^3 \end{eqnarray*} that is normalized to \begin{eqnarray*} && 1.\fbox{0000000000000000000000000000000000000000000000000100} \times 2^0, \end{eqnarray*} which is \(1+2^{-50}\). After subtracting \(1\), the result is that the double precision floating point version of \((8.3-7.3)-1\) is \(2^{-50}\).

15(b) \((8.4)_{10} = 1.000\overline{0110}\times 2^{3}\), and rounded, fl\((8.4)=1.0000\ 1100\ 1100\ldots 1100\ 1101\times 2^{3}\). \((7.4)_{10} = 1.11\overline{0110}\times 2^{2}\), and rounded, fl\((7.4)=1.1101\ 1001\ 1001\ldots 1001\ 1010\times 2^{2}\). Subtracting gives \begin{eqnarray*} && 1.\fbox{0000110011001100110011001100110011001100110011001101} \times 2^3\\ &-& 0.\fbox{1110110011001100110011001100110011001100110011001101} \times 2^3 \nonumber\\ &=& 0.\fbox{0010000000000000000000000000000000000000000000000000} \times 2^3 \end{eqnarray*} which is \(1\). After subtracting \(1\), the result is that the double precision floating point version of \((8.4-7.4)-1\) is \(0\).

15(c) \((8.8)_{10} = 1.000\overline{1100}\times 2^{3}\), and rounded, fl\((8.8)=1.0001\ 1001\ 1001\ldots 1001\ 1010\times 2^{3}\). \((7.8)_{10} = 1.11\overline{1100}\times 2^{2}\), and rounded, fl\((7.8)=1.1111\ 0011\ 0011\ldots 0011\ 0011\times 2^{2}\). Subtracting gives \begin{eqnarray*} && 1.\fbox{0001100110011001100110011001100110011001100110011010}\ 0 \times 2^3\\ &-& 0.\fbox{1111100110011001100110011001100110011001100110011001}\ 1 \times 2^3 \nonumber\\ &=& 0.\fbox{0010000000000000000000000000000000000000000000000000}\ 1 \times 2^3 \end{eqnarray*} that is normalized to \begin{eqnarray*} && 1.\fbox{0000000000000000000000000000000000000000000000000100} \times 2^0, \end{eqnarray*} which is \(1+2^{-50}\). After subtracting \(1\), the result is that the double precision floating point version of \((8.8-7.8)-1\) is \(2^{-50}\).


17(a) \((5)_{10} = (101.)_2\). The representation of an E2M1 floating point number is \(1.b \times 2^e\). Justify: \(1.01\times 2^2\). Round: \( 1.\fbox{0}1\times 2^2 \to 1.0\times 2^2\), where the Rounding to Nearest Rule is used to round down, since the 1 in the bit following the mantissa is followed by all zeros, and the mantissa is already 0. The rounding error is 1, the difference between 5 and 4.

17(b) \((2.75)_{10} = (10.11)_2\). Justify: \(1.011\times 2^1\). Round: \(1.\fbox{0}11 \times 2^1 \to 1.1\times 2^1\), after rounding up. The rounding error is \(0.25\).

17(c) \((4/3)_{10} = (1.\overline{01})_2\). Justify: \(1.\overline{01}\times 2^0\). Round: \(1.\fbox{0}101\ldots\times 2^0 \to 1.1\times 2^0\). The rounding error ia \(1/6\).


19(a) \( (10/3)_{10} = (11.\overline{01})_2\). Justify: \(1.\overline{10}\times 2^1\). In E4M3, the rounding is \(1.\fbox{101}0101\ldots \times 2^1 \to 1.101\times 2^1\), which corresponds to \(3.25\) in base 10. The rounding error is \(1/12\). In E5M2, the rounding is \(1.\fbox{10}1010\ldots \times 2^1 \to 1.11\times 2^1\) after rounding up, which corresponds to \(3.5\) in base 10. The rounding error is \(1/6\).

19(b) \( (14.75)_{10} = (1110.11)_2\). Justify: \(1.11011\times 2^3\). In E4M3, the rounding is \(1.\fbox{110}11 \times 2^3 \to 1.111\times 2^3\), which corresponds to \(15\) in base 10. The rounding error is \(0.25\). In E5M2, the rounding is \(1.\fbox{11}011\times 2^3 \to 1.11\times 2^3\) after rounding down, which corresponds to 14 in base 10. The rounding error is \(0.75\).

19(c) \( (1.9)_{10} = (1.1\overline{1100})_2\). Justify: \(1.1\overline{1100}\times 2^0\). In E4M3, the rounding is \(1.\fbox{111}\overline{0011} \times 2^0\to 1.111\times 2^0\), which corresponds to \(1.875\) in base 10. The rounding error is \(0.025\). In E5M2, the rounding is \(1.\fbox{11}\overline{1001}\times 2^0 \to 10.00\times 2^0 = 1.00\times 2^1\) after rounding up, which corresponds to 2 in base 10. The rounding error is \(0.1\).