Floating-point representation

Computer Science · Data representation

Question 1 of 10

0

    An 8-bit floating-point format stores 1 sign bit, then 4 exponent bits (bias 7), then 3 mantissa bits. A normalised number has the value (−1)^sign × 1.mantissa (in binary) × 2^(exponent field − 7). Exponent fields of all 0s and all 1s are reserved for special values (zero, infinity, NaN), so normalised numbers use the exponent fields in between. A positive number is stored with exponent field 9 (denary) and mantissa bits 011. What is the denary value of the number?

    Decimals (0.75 or 0,75), fractions (3/4) and mixed numbers (1 1/2) are accepted. Do not use thousands separators.

    How to type your answer
    • Fractions: 3/4. Mixed numbers: 1 1/2.
    • Decimals with a point or a comma: 0.75 or 0,75.
    • Negative numbers start with a minus: -3/4.
    • Percentages need the % sign: 75%.

    Stuck? Read the explanation

    Unlocks at a streak of 5 correct answers in a row.

    Print a free worksheet (PDF)

    Embed this practice on your site or class page

    Paste this HTML into your page. Students practise right there; it is free and needs no account.

    Floating-point representation explained

    Real numbers such as 6.5 or 0.001 are stored in computers using floating-point representation. The number is split into two parts. The mantissa holds the significant digits in binary, and the exponent says where the binary point sits by giving a power of two. The stored number is the mantissa multiplied by two raised to the power of the exponent. This allows very large and very small values to be stored with the same number of bits.

    In the AQA A-level method, the mantissa is normalised so that its first two bits differ, which gives the most accurate form, and both parts are written in two's complement. In IEEE 754, used by most modern processors, a single-precision number has 32 bits: one sign bit, eight exponent bits and 23 mantissa bits. Because only a finite number of bits is used, many decimal fractions, including 0.1, cannot be stored exactly, so a small round-off error results.

    Worked example

    Store 6.5 using a 5-bit mantissa (one sign bit followed by four bits after the point) and a 4-bit two's complement exponent.

    1. Write 6.5 in binary: 110.1.
    2. Normalise: 110.1=0.1101×23110.1 = 0.1101 \times 2^{3}, so the mantissa is 0.1101 and the exponent is 3.
    3. Store the mantissa as 0 1101 (sign bit 0, then the four bits) and the exponent as 0011.
    4. Check: 0.1101 in binary is 0.8125, and 0.8125×23=6.50.8125 \times 2^{3} = 6.5.

    The stored value is exactly 6.5, because all of its bits fit.

    What you will practise

    New numbers every time you practise. Levels: Easy, Medium, Hard. Each answer is followed by a worked explanation.

    Example questions

    • Easy

      An 8-bit floating-point format stores 1 sign bit, then 4 exponent bits (bias 7), then 3 mantissa bits. A normalised number has the value (−1)^sign × 1.mantissa (in binary) × 2^(exponent field − 7). Exponent fields of all 0s and all 1s are reserved for special values (zero, infinity, NaN), so normalised numbers use the exponent fields in between. The 8 bits 0 0111 100 (sign, exponent, mantissa) are stored. What is the denary value of the number?

    • Medium

      An 8-bit floating-point format stores 1 sign bit, then 4 exponent bits (bias 7), then 3 mantissa bits. A normalised number has the value (−1)^sign × 1.mantissa (in binary) × 2^(exponent field − 7). Exponent fields of all 0s and all 1s are reserved for special values (zero, infinity, NaN), so normalised numbers use the exponent fields in between. Numbers with an unbiased exponent of 0 lie between 2^0 and 2^1. What is the difference between two neighbouring stored numbers in that range?

    • Hard

      An 8-bit floating-point format stores 1 sign bit, then 3 exponent bits (bias 3), then 4 mantissa bits. A normalised number has the value (−1)^sign × 1.mantissa (in binary) × 2^(exponent field − 3). Exponent fields of all 0s and all 1s are reserved for special values (zero, infinity, NaN), so normalised numbers use the exponent fields in between. The number 2.125 is stored exactly. What is the denary value of its exponent field?