4.1.8

Floating Point Arithmetic

Test yourself

Floating Point Addition

When adding floating point binary numbers, it is important to ensure each number is represented with the same level of precision. This means that the exponents must be the same.

Illustrative background for AdditionIllustrative background for Addition ?? "content

Addition

  • The example below shows the addition of two normalised 12-bit floating point numbers, with 8-bit mantissas and 4-bit exponents:
    • 0.10110000011 + 0.11100000010
Illustrative background for Matching exponentsIllustrative background for Matching exponents ?? "content

Matching exponents

  • The first step is to ensure the exponents of the two numbers match, by adding 1 to the exponent of the second number (2) to match that of the first (3).
  • Adding 1 to the exponent of the second number moves the binary point of the mantissa in this number one place to the left:
    • 0.11100000010 \rightarrow 0.01110000011
Illustrative background for Compute the additionIllustrative background for Compute the addition ?? "content

Compute the addition

  • The two mantissas can then be added together:
    • 0.1011000 + 0.0111000 = 1.0010000
  • Including the exponent gives 1.00100000011.
Illustrative background for Normalise the resultIllustrative background for Normalise the result ?? "content

Normalise the result

  • Check that the result is normalised, and move the binary point as necessary.
  • If the binary point gets moved, remember to change the exponent accordingly.

Floating Point Subtraction

When subtracting floating point binary numbers, it is important to ensure each number is represented with the same level of precision. This means that the exponents must be the same.

Illustrative background for SubtractionIllustrative background for Subtraction ?? "content

Subtraction

  • The example below shows the subtraction of two normalised 12-bit floating point numbers, with 8-bit mantissas and 4-bit exponents:
    • 0.10110000011 − 0.11100000010
Illustrative background for Matching exponentsIllustrative background for Matching exponents ?? "content

Matching exponents

  • The first step is to ensure the exponents of the two numbers match, by adding 1 to the exponent of the second number (2) to match that of the first (3).
  • Adding 1 to the exponent of the second number moves the binary point of the mantissa in this number one place to the left:
    • 0.11100000010 \rightarrow 0.01110000011
Illustrative background for Two's complementIllustrative background for Two's complement ?? "content

Two's complement

  • The next step is to find the twos complement of the second number:
    • 1.1001000
Illustrative background for Add mantissasIllustrative background for Add mantissas ?? "content

Add mantissas

  • The two mantissas can then be added:
    • 0.1011000 + 1.1001000 = 0.1000000
  • Note that the first digit of the two's complement corresponds to -1 in decimal.
  • Factor this in when you do the addition.
Illustrative background for Normalise the resultIllustrative background for Normalise the result ?? "content

Normalise the result

  • The result should then be normalised by moving the binary point one place to the left.
  • That means we add 1 to the exponent:
    • 1.00100000100

Jump to other topics

1Components of a Computer

2Software & Software Development

3Exchanging Data

4Data Types, Data Structures & Algorithms

5Legal, Moral, Cultural & Ethical Issues

6Elements of Computational Thinking

6.1Thinking Abstractly

6.2Thinking Procedurally

6.3Thinking Logically

7Problem Solving & Programming

8Algorithms

Go student ad image

Unlock your full potential with GoStudent tutoring

  • Affordable 1:1 tutoring from the comfort of your home

  • Tutors are matched to your specific learning needs

  • 30+ school subjects covered

Book a free trial lesson