CSwithZain
WhatsApp Join a class

A Level 9618 · Paper 3 · 13.3

Floating-point numbers, representation and manipulation

How real numbers are stored in binary as a mantissa and an exponent. Read the notes, try the past-paper questions, then check the mark scheme.

Past papers from June 2021 to June 202621 questions · 135 marks

    In this subtopic

    • The two's complement mantissa and exponent format
    • What changes when more bits go to the mantissa or to the exponent
    • Converting between binary floating point and denary
    • Normalising a number, and why it is done
    • Rounding errors, underflow and overflow

    13.3 · 1 of 7Book page Contents

    Floating-point representation

    Floating-point notation is a way of representing very small or very large numbers with the same number of bits. It is like scientific notation in denary.

    A floating-point number has two parts: the mantissa and the exponent. Its value is M × 2E, where M is the mantissa and E is the exponent. There is no separate sign bit: both parts are usually stored in two’s complement (the question will say so), so the first bit of the mantissa is worth –1, as the place values below show.

    Because the first bit is negative, a mantissa or exponent that starts with 1 is negative, and one that starts with 0 is positive. The question should always say that two’s complement is used.

    Worked example

    Calculate the denary value of the floating-point binary number 0010101010110, where 9 bits are used for the mantissa followed by 4 bits for the exponent, both in two’s complement.

    1. Step 1
      Split the number into the mantissa (0.01010101) and the exponent (0110).
    2. Step 2
      Work out the exponent: 0110 = 6.
    3. Step 3
      Move the binary point in the mantissa six places to the right: 0010101.01
    4. Step 4
      Convert to denary: 16 + 4 + 1 + 0.25 = 21.25

    Practise this: past-paper questions

    Show 5 more

    13.3 · 2 of 7Book pages Contents

    Normalisation

    Normalisation makes the most of the bits available, so the number is stored as precisely as possible. For a positive number, the leading zeros are removed; for a negative number, the leading ones are removed. So a normalised mantissa always starts 0.1 (positive) or 1.0 (negative).

    To normalise, move the binary point in the mantissa until it starts 0.1 or 1.0. Then change the exponent: take away the number of places if the point moved right, and add it if the point moved left.

    Worked example

    The floating-point binary number 000101010101 has an 8-bit mantissa followed by a 4-bit exponent, both in two’s complement. Find the normalised version of this number.

    1. Step 1
      Split the number into the mantissa (0.0010101) and the exponent (0101).
    2. Step 2
      Move the binary point right until the mantissa starts 0.1. Moving it two places gives 0.10101.
    3. Step 3
      The mantissa must stay 8 bits, so add two zeros on the right. This does not change its value: 0.1010100.
    4. Step 4
      The point moved two places right, so take 2 from the exponent: 0101 (5) – 2 = 3 = 0011.
    5. Step 5
      Join them together: the normalised number is 010101000011.

    Why binary numbers are stored in normalised form

    • To store the largest range of numbers in the smallest number of bits.
    • Normalisation removes the leading zeros (or ones), which carry no information.
    • It gives the most significant bits, so the most precision for the number of bits available.
    • It stops the same number having several different representations.

    13.3 · 3 of 7Book page Contents

    From denary to floating point

    Worked example

    Give the denary value 27.75 as a normalised floating-point binary number, using 8 bits for the mantissa and 4 bits for the exponent, both in two’s complement.

    1. Step 1
      Write 27.75 as a fixed-point binary number in two’s complement: 011011.11
    2. Step 2
      Move the binary point five places to the left so the mantissa is normalised: 0.1101111
    3. Step 3
      The point moved five places left, so add 5 to the exponent: 0 + 5 = 5 = 0101.
    4. Step 4
      Join the mantissa and exponent: the normalised value is 011011110101.

    When the fraction part is not a simple one, convert it with the "multiply by two and record the whole number parts" method. For 8.63:

    Worked example

    Convert the fraction .63 to binary.

    1. Step 1
      .63 × 2 = 1.26, so write down 1: the fraction so far is .1
    2. Step 2
      .26 × 2 = 0.52, so write down 0: .10
    3. Step 3
      .52 × 2 = 1.04, so write down 1: .101
    4. Step 4
      .04 × 2 = 0.08, so write down 0: .1010
    5. Step 5
      Multiplying .08 by 2 again and again will give many zeros before the next 1, so stop here. .63 has been stored as .625, which is an approximation. 8.63 becomes 1000.1010, and the final representation, with a 10-bit mantissa and a 4-bit exponent, is 0100010100 for the mantissa and 0100 for the exponent.

    Practise this: past-paper questions

    Show 13 more

    13.3 · 4 of 7Book page Contents

    Negative numbers

    In two’s complement the first bit is negative: it is worth –1 in the mantissa and –8 in a 4-bit exponent. So a mantissa or an exponent that starts with 1 is negative. A normalised positive mantissa starts 0.1 and a normalised negative one starts 1.0. These examples use an 8-bit mantissa and a 4-bit exponent.

    Worked example 1

    Find the denary value of the mantissa 10100000 with the exponent 1110.

    1. Step 1
      The exponent 1110 = –8 + 4 + 2 = –2.
    2. Step 2
      The mantissa 1.0100000 = –1 + 0.25 = –0.75.
    3. Step 3
      The value is –0.75 × 2–2 = –0.75 × 0.25 = –0.1875.

    Worked example 2

    Give –3.75 as a normalised floating-point number.

    1. Step 1
      Write 3.75 in binary: 011.11 (the 0 at the front is the sign bit).
    2. Step 2
      Make it negative with two’s complement. Flip every bit and add 1 to the last place: 100.00 + 0.01 = 100.01 (check: –4 + 0.25 = –3.75).
    3. Step 3
      Move the binary point 2 places left so the mantissa starts 1.0: 1.0001000. The point moved 2 places, so the exponent is 2 = 0010.
    4. Step 4
      The answer is 10001000 0010. Check: –1 + 0.0625 = –0.9375, and –0.9375 × 22 = –3.75.

    Worked example 3

    Normalise the mantissa 11101000 with the exponent 0011.

    1. Step 1
      A negative mantissa must start 1.0. 1.1101000 has two extra 1s at the front, so move the bits 2 places left: 1.0100000 (this is the same as moving the binary point 2 places right).
    2. Step 2
      The bits moved 2 places left, so take 2 from the exponent: 3 – 2 = 1 = 0001. The answer is 10100000 0001 (both equal –1.5).

    Practise this: past-paper questions

    Show 12 more

    13.3 · 5 of 7Book pages Contents

    Range and precision

    The number of bits given to the mantissa and to the exponent affects both the range and the precision of the numbers that can be stored. More bits for the exponent means larger (and smaller) numbers can be stored, but that leaves fewer bits for the mantissa, so numbers are less precise. More bits for the mantissa gives more precision, but a smaller range.

    Worked example

    Calculate the largest number that can be stored in 8 bits if 3 bits are used for the mantissa and 5 bits for the exponent.

    1. Step 1
      The largest number is 011 01111: the largest positive mantissa with the largest positive exponent.
    2. Step 2
      The mantissa is 0.11, and the exponent 01111 = 15, so the binary point moves 15 places to the right.
    3. Step 3
      0110000000000000 = 16384 + 8192 = 24576. The largest number is 24 576.

    Worked example

    Calculate the largest number that can be stored in 8 bits if 5 bits are used for the mantissa and 3 bits for the exponent.

    1. Step 1
      The largest number is 01111 011.
    2. Step 2
      The mantissa is 0.1111 and the exponent 011 = 3, so the binary point moves 3 places to the right.
    3. Step 3
      0111.1 = 7.5. So with fewer exponent bits, the range is far smaller.

    With an 8-bit mantissa and an 8-bit exponent, both in two’s complement and normalised, these are the limits:

    Largest positive number

    01111111
    01111111
    = 127/128 × 2127

    Smallest positive number

    01000000
    10000000
    = 1/2 × 2–128

    Smallest-magnitude negative number (closest to zero)

    10111111
    10000000
    = –65/128 × 2–128

    Largest-magnitude negative number (furthest from zero)

    10000000
    01111111
    = –1 × 2127

    In each row: the 8-bit mantissa, then the 8-bit exponent.

    The mantissa and exponent trade-off

    • The trade-off is between range and precision.
    • More bits for the mantissa means fewer bits for the exponent, and fewer bits for the mantissa means more bits for the exponent.
    • More bits for the mantissa gives better precision.
    • More bits for the exponent gives a larger range of numbers.

    13.3 · 6 of 7Book pages Contents

    Rounding errors

    Because of the trade-off between range and precision, some numbers cannot be stored exactly. A rounding error happens when a number has to be approximated. For example, 76.65625 needs a 13-bit mantissa, 0100110010101, with the exponent 0111. With only 10 bits for the mantissa, the three rightmost bits are lost, and the number stored is 76.5. This is close, but not exact.

    Some numbers can never be stored exactly. 1/3 in binary is 0.010101... with the 01 repeating for ever, and there are only a fixed number of bits, so it must be rounded. It could be stored as 0 1010101 1111 (mantissa 0.1010101, exponent –1).

    The size of the error can be given in two ways:

    • The absolute error is the difference between the real number and the number stored. For 76.65625 stored as 76.5, it is 0.15625.
    • The relative error is the absolute error as a percentage of the real value: 0.15625 / 76.65625 × 100 = about 0.2%.

    13.3 · 7 of 7Book pages Contents

    Underflow and overflow

    Underflow happens when a number is too small (too close to zero) to be represented. With an 8-bit mantissa and a 4-bit exponent, normalised, the smallest exponent is 1000 (–8) and the smallest positive mantissa is 0.1000000. So the smallest positive number is 0 1000000 1000, which is 1/2 × 2–8 = 1/512. A result smaller than 1/512 causes an underflow error.

    Overflow happens when a number is too large to be represented. In the same system, the largest number is 0 1111111 0111, which is 127/128 × 27 = 127. A result larger than 127 causes an overflow error, and the number cannot be stored.

    Both can happen with negative numbers too: a negative number can be too far from zero (overflow) or too close to zero (underflow).

    13.3

    Concepts in 13.3

    Every idea explained in 13.3, and where else in the notes it is used.

    ConceptIn one lineAlso used in
    absolute errorThe difference between the real number and the number stored.only here
    exponentThe power of 2 that the mantissa is multiplied by.13.3 Normalisation, 13.3 From denary to floating point, 13.3 Negative numbers, 13.3 Range and precision, 13.3 Rounding errors, 13.3 Underflow and overflow
    floating-pointA way to store numbers as a mantissa and an exponent, with the value M × 2^E.13.3 Normalisation, 13.3 From denary to floating point, 13.3 Negative numbers
    mantissaThe part of a floating-point number that holds its significant digits.13.3 Normalisation, 13.3 From denary to floating point, 13.3 Negative numbers, 13.3 Range and precision, 13.3 Rounding errors, 13.3 Underflow and overflow
    normalisationMoving the binary point so the mantissa starts 0.1 or 1.0, giving the most precision.13.3 From denary to floating point, 13.3 Negative numbers, 13.3 Range and precision, 13.3 Underflow and overflow
    overflowA number too large to be represented.15.2 The four-bit binary adder
    precisionHow exactly a number can be stored.13.3 Normalisation, 13.3 Rounding errors
    rangeHow large and how small the numbers that can be stored are.only here
    relative errorThe absolute error as a percentage of the real value.only here
    rounding errorThe error when a number must be approximated to fit the bits available.only here
    underflowA number too close to zero to be represented.only here

    When you want more than reading

    The notes are the front door. The class is where it clicks.

    Join a class →Ask on WhatsApp