IEEE-754 format
IEEE-754 format
The IEEE-754 format is a standard specified by the **IEEE** for representing floating-point binary numbers. The two versions of the format that are most common are **single precision** (32-bits) and **double precision** (64-bits).
Link to original
IEEE-754 formats specify:
- Number of bits for the significand and exponent.
- A bias for the exponent.
Exponent bias
The bias is an offset which is always applied to the exponent of a floating point number, $127$ for single precision and $1023$ for double precision.
We use a bias instead of two’s complement as it allows for the numeric ordering to be the same as the lexicographic ordering which allows fast size comparisons of numbers.
Example: convert single-precision exponent :
Subtract the bias to find .
Link to original - A normalised format.
Normalisation
When the significand of a floating point number is normalised, there is an implied leading before the stored significand.
By normalising floating point values, we: ?
- Gain an extra bit of precision because of the implied leading .
- Ensure that there is a unique representation for values. In non-normalised form, can be represented as , and so on.
Bit lengths for IEEE-754 format
Each IEEE-754 format uses a different number of bits for each part of the number:
Link to original
Format Sign Exponent Significand Total single 1 8 23 32 double 1 11 52 64
The sign bit behaves the same way as in signed-magntiude. The exponent and significand are not just unsigned.
title: Example 1
Take $11000001001011000000000000000000$.
We first break it down to individual components: $\color{green}1 \color{blue}1000010\color{red}01011$.
- $\color{green}1$ is the $\color{green}\text{sign bit}$ which tells us it is negative.
- $\color{blue}1000010$ is the $\color{blue}\text{exponent}$.
This value is $130_{10} - 127_{10} (\text{bias}) = 3_{10}$.
- $\color{red}01011$ is the $\color{red}\text{significand}$.
Significand is $1.01011$ with the implied leading $1$.
So, our final value is $- 1.01011 \times 2^3 = - 1010.11_2 \rightarrow - 10.75_{10}$.title: Example 2
Take $-133.25_{10}$.
Convert to binary and normalise:
$$
\begin{aligned}
133.25 &\rightarrow 1000101.01 \times 2^0 \\
&= 1.000010101 \times 2^7 \\
&= {\color{red}00001010100000000000000_2} \\
\\
2^7 &\rightarrow 7 + 127 \\
&= 137 \\
&= {\color{blue}10000110_2}
\end{aligned}
$$
Sign is negative so $\color{green}1$.
Hence final value is ${\color{green}1}{\color{blue}10000110}{\color{red}00001010100000000000000}$.Special values
Using normalised form, it is not possible to represent , so there is a special value specified which we use for .
| Decimal | IEEE-754 single precision |
|---|---|