4.1.8
Floating Point Arithmetic
Floating Point Addition
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 Addition](https://image-v2.cdn.app.senecalearning.com/2020-08/e9a993c8-fe62-442c-8e81-f755a9c7bd78/Screenshot%202020-08-25%20at%2013.18.53-min,h_400,q_80,w_640.png)
![Illustrative background for Addition ?? "content](https://image-v2.cdn.app.senecalearning.com/2020-08/e9a993c8-fe62-442c-8e81-f755a9c7bd78/Screenshot%202020-08-25%20at%2013.18.53-min,h_400,q_80,w_640.png)
Addition
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 exponents](https://image-v2.cdn.app.senecalearning.com/2020-08/fe17169a-1973-4929-9898-1560f7b8ecd7/Screenshot%202020-08-25%20at%2013.18.55-min,h_400,q_80,w_640.png)
![Illustrative background for Matching exponents ?? "content](https://image-v2.cdn.app.senecalearning.com/2020-08/fe17169a-1973-4929-9898-1560f7b8ecd7/Screenshot%202020-08-25%20at%2013.18.55-min,h_400,q_80,w_640.png)
Matching exponents
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 0.01110000011
![Illustrative background for Compute the addition](https://image-v2.cdn.app.senecalearning.com/2020-08/4e1a3f0e-3c91-4a3b-96c8-1511436e0655/Screenshot%202020-08-25%20at%2013.34.43-min,h_400,q_80,w_640.png)
![Illustrative background for Compute the addition ?? "content](https://image-v2.cdn.app.senecalearning.com/2020-08/4e1a3f0e-3c91-4a3b-96c8-1511436e0655/Screenshot%202020-08-25%20at%2013.34.43-min,h_400,q_80,w_640.png)
Compute the addition
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 result](https://image-v2.cdn.app.senecalearning.com/2020-08/afd41355-7de8-4620-a13e-3c7515ee225c/Screenshot%202020-08-25%20at%2013.34.45-min,h_400,q_80,w_640.png)
![Illustrative background for Normalise the result ?? "content](https://image-v2.cdn.app.senecalearning.com/2020-08/afd41355-7de8-4620-a13e-3c7515ee225c/Screenshot%202020-08-25%20at%2013.34.45-min,h_400,q_80,w_640.png)
Normalise the result
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
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 Subtraction](https://image-v2.cdn.app.senecalearning.com/2020-08/d8f64412-937d-45e1-8f91-44bbf1754051/Screenshot%202020-08-25%20at%2017.08.38-min,h_400,q_80,w_640.png)
![Illustrative background for Subtraction ?? "content](https://image-v2.cdn.app.senecalearning.com/2020-08/d8f64412-937d-45e1-8f91-44bbf1754051/Screenshot%202020-08-25%20at%2017.08.38-min,h_400,q_80,w_640.png)
Subtraction
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 exponents](https://image-v2.cdn.app.senecalearning.com/2020-08/c50434cf-ec5c-485f-84be-6175a66c9767/Screenshot%202020-08-25%20at%2017.08.40-min,h_400,q_80,w_640.png)
![Illustrative background for Matching exponents ?? "content](https://image-v2.cdn.app.senecalearning.com/2020-08/c50434cf-ec5c-485f-84be-6175a66c9767/Screenshot%202020-08-25%20at%2017.08.40-min,h_400,q_80,w_640.png)
Matching exponents
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 0.01110000011
![Illustrative background for Two's complement](https://image-v2.cdn.app.senecalearning.com/2020-08/770f7c15-3347-4841-b187-c0f8643a22cf/Screenshot 2020-08-25 at 17.09.00-min,h_400,q_80,w_640.png)
![Illustrative background for Two's complement ?? "content](https://image-v2.cdn.app.senecalearning.com/2020-08/770f7c15-3347-4841-b187-c0f8643a22cf/Screenshot 2020-08-25 at 17.09.00-min,h_400,q_80,w_640.png)
Two's complement
Two's complement
- The next step is to find the twos complement of the second number:
- 1.1001000
![Illustrative background for Add mantissas](https://image-v2.cdn.app.senecalearning.com/2020-08/0fa2dd8e-f77e-4213-b933-13b505d9cfd9/Screenshot%202020-08-25%20at%2017.46.12-min,h_400,q_80,w_640.png)
![Illustrative background for Add mantissas ?? "content](https://image-v2.cdn.app.senecalearning.com/2020-08/0fa2dd8e-f77e-4213-b933-13b505d9cfd9/Screenshot%202020-08-25%20at%2017.46.12-min,h_400,q_80,w_640.png)
Add mantissas
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 result](https://image-v2.cdn.app.senecalearning.com/2020-08/6bfa96f7-9cf1-4dbe-873d-c544ae6b750c/Screenshot%202020-08-25%20at%2017.46.14-min,h_400,q_80,w_640.png)
![Illustrative background for Normalise the result ?? "content](https://image-v2.cdn.app.senecalearning.com/2020-08/6bfa96f7-9cf1-4dbe-873d-c544ae6b750c/Screenshot%202020-08-25%20at%2017.46.14-min,h_400,q_80,w_640.png)
Normalise the result
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
1Components of a Computer
1.1Structure & Function of the Processor
1.2Types of Processors
2Software & Software Development
2.1Systems Software
2.2Applications Generation
2.3Software Development
3Exchanging Data
3.1Compression, Encryption & Hashing
3.3Networks
4Data Types, Data Structures & Algorithms
4.1Data Types
5Legal, Moral, Cultural & Ethical Issues
5.1Computing Related Legislation
6Elements of Computational Thinking
6.1Thinking Abstractly
6.2Thinking Procedurally
6.3Thinking Logically
7Problem Solving & Programming
7.1Programming Techniques
7.2Programming Construction
Jump to other topics
1Components of a Computer
1.1Structure & Function of the Processor
1.2Types of Processors
2Software & Software Development
2.1Systems Software
2.2Applications Generation
2.3Software Development
3Exchanging Data
3.1Compression, Encryption & Hashing
3.3Networks
4Data Types, Data Structures & Algorithms
4.1Data Types
5Legal, Moral, Cultural & Ethical Issues
5.1Computing Related Legislation
6Elements of Computational Thinking
6.1Thinking Abstractly
6.2Thinking Procedurally
6.3Thinking Logically
7Problem Solving & Programming
7.1Programming Techniques
7.2Programming Construction
![Go student ad image](/en-GB/revision-notes/_next/image?url=%2Fen-GB%2Frevision-notes%2Fimages%2Fgo-student-uk-ad.jpg&w=640&q=100)
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