2 To assist with understanding the limitations of floating point representations, we have produced a plot of the positive real numbers which can be represented exactly by an 8 bit floating point number encoded in the IEEE-754 format. We could not find any similar visualisations in the literature.
4 In Figure \ref{floats.pdf} we show two encodings using (1,2,5) and (1,3,4) bits to encode (sign, exponent, mantissa) respectively. For each distinct value of the exponent, the successive floating point representations lie on a straight line with constant slope. As the exponent increases, larger values are represented, but the distance between successive values increases; this can be seen in Figure \ref{floats_diff.pdf}. The marked single point discontinuity at \verb/0x10/ and \verb/0x20/ occur when $e$ leaves the denormalised region and the encoding of $m$ changes. We have also plotted a fixed point representation for comparison; fixed point and integer representations appear on straight lines.
7 The earlier example $7.25$ would be converted to a (1,3,4) floating point representation as follows:
9 \item Determine the fixed point representation $7.25 = 111.01_2$
10 \item Determine the sign bit; in this case $s = 0$
11 \item Calculate the exponent by shifting the point $111.01_2 = 1.1101_2 \times 2^2 \implies e = 2 = 10_2$
12 \item Determine the exponent encoding; in IEEE-754 equal to the number of exponent bits is added so $e_{enc} = e+3 = 5 = 101_2$
13 \item Remove the implicit bit if the encoded exponent $\neq 0$; $1.1101_2 \to .1101_2$
14 \item Combine the three bit strings$0,101,1101$
15 \item The final encoding is $01011101 \equiv \text{0x5D}$
17 This particular example can be encoded exactly; however as there are an infinite number of real values and only a finite number of floats, in general a value must be $7.26$ must be rounded or truncated at Step 3.
20 \input{chapters/Background/Floats/Operations}
23 %\begin{minipage}[t]{0.45\textwidth}
26 \includegraphics[width=0.8\textwidth]{figures/floats.pdf}
27 \caption{Positive 8-Bit Number Representations} \label{floats.pdf}
30 %\begin{minipage}[t]{0.45\textwidth}
33 \includegraphics[width=0.8\textwidth]{figures/floats_diff.pdf}
34 \caption{Difference between successive numbers} \label{floats_diff.pdf}
37 % \caption{8 bit float and fixed point representations a) As mapped to real values b) The distance between each representation}\label{floats.pdf}