---
title: "Floating point addition and subtraction"
subject: "Computer Organization and Architecture"
chapter: 5
key: "semester_5/computer_organization_and_architecture:fp-add-sub"
source: https://www.bctengineer.com/q/semester_5/computer_organization_and_architecture/fp-add-sub
site: BCT Engineering
---

# Floating point addition and subtraction

Computer Organization and Architecture · Chapter 5: Computer Arithmetic

- Asked in: 2078 Kartik, 6 marks; 2078 Bhadra, 3+3 marks; 2074 Chaitra, 10 marks; 2073 Shrawan, 6 marks; 2070 Asar, 4 marks; 2069 Asar, 6 marks (asked 6 times)
- Video: [Floating Point Arithmetic on Addition and Subtraction](https://www.youtube.com/watch?v=w7NQTb1FTDU) — TutorialsPoint
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_5/computer_organization_and_architecture/fp-add-sub
- Whole chapter: https://www.bctengineer.com/md/semester_5/computer_organization_and_architecture/chapter-5

## Question

Explain the floating point addition and subtraction algorithm with flowchart and example.

## Short answer

To add/subtract, align exponents by shifting the smaller mantissa right. Then add/subtract mantissas, normalize (shift left on leading zero, shift right on overflow). Example: 1.101×2³ + 0.011×2³ = 10.000×2³ → 1.000×2⁴ = 16.

## Answer

A floating-point number is X = m × 2^e (mantissa m, exponent e; the exponent is biased in IEEE 754). To add or subtract two such numbers, their exponents must first be made equal.

#### Algorithm (steps)
1. **Check for zeros:** if either operand is 0, the result is the other operand (for subtraction, with its sign changed if it is the subtrahend).
2. **Align the mantissas:** compare the exponents. Shift the mantissa of the number with the smaller exponent right by the difference, increasing its exponent with each shift, until the exponents are equal.
3. **Add or subtract the mantissas** (for subtraction, change the sign of the second operand and add) using the signed-mantissa rules. The result gets the common exponent.
4. **Check for a zero result** and for mantissa overflow: if the mantissa overflows (carry out), shift it right by one and increase the exponent by 1.
5. **Normalise the result:** if the mantissa has leading zeros, shift it left and decrease the exponent for each shift, until the first digit is non-zero (1.xxx in binary).
6. **Check for exponent overflow or underflow**, round the mantissa if needed, and give the result.

```text
        Start
          |
   Is X or Y zero? --yes--> result = other operand
          | no
   Align mantissas (shift smaller right)
          |
   Add / subtract mantissas
          |
   Result zero? --yes--> result = 0
          | no
   Mantissa overflow? --yes--> shift right, e = e + 1
          | no
   Normalise (shift left, e = e - 1)
          |
   Exponent overflow/underflow? --yes--> report error
          | no
         Stop
```

#### Example 1 (addition): 13 + 3
X = 1.101 × 2³ (13), Y = 1.100 × 2¹ (3).
- Exponent difference = 3 - 1 = 2; shift Y right 2 places: 0.011 × 2³.
- Add: 1.101 + 0.011 = 10.000 (carry out).
- Overflow: shift right 1 and increment the exponent: 1.000 × 2⁴.
- Result = 1.000 × 2⁴ = **16** ✓

#### Example 2 (subtraction): 13 - 3
- Align as above: Y = 0.011 × 2³.
- Subtract: 1.101 - 0.011 = 1.010.
- Already normalised: 1.010 × 2³ = 1.25 × 8 = **10** ✓

(If the result has leading zeros, for example 1.101 - 1.100 = 0.001, shift it left 3 times and decrease the exponent by 3.)

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Before adding floating-point numbers, what must be done?
   A. Shift the mantissa of the number with the smaller exponent right until exponents are equal
   B. Shift the larger mantissa left
   C. Multiply mantissas
   D. Normalise first
   Answer: A. Exponents must match; the smaller number is shifted right, increasing its exponent per shift. (Key point: Exponent alignment)

2. If adding mantissas produces a carry out, what is done?
   A. Shift right by one and increase exponent by 1
   B. Shift left by one and decrease exponent
   C. Discard the carry
   D. Report error
   Answer: A. E.g. 1.101 + 0.011 = 10.000 becomes 1.000 x 2^4. (Key point: Mantissa overflow)

3. When the result has leading zeros, normalisation:
   A. Shifts the mantissa left and decreases the exponent per shift
   B. Shifts right and increases the exponent
   C. Adds the bias
   D. Leaves it unchanged
   Answer: A. Normalising makes the first digit non-zero (1.xxx), compensating with the exponent. (Key point: Normalisation)

4. How is subtraction handled?
   A. Change the sign of the second operand and add
   B. Divide the mantissas
   C. Subtract the exponents only
   D. It needs a separate algorithm without alignment
   Answer: A. The same add procedure is used with the sign of the subtrahend flipped. (Key point: Subtraction)

## Related in Computer Organization and Architecture

- [Floating point division algorithm](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_organization_and_architecture%3Afp-division) — Computer Organization and Architecture, chapter 5, asked 4×
- [Floating point multiplication](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_organization_and_architecture%3Afp-multiplication) — Computer Organization and Architecture, chapter 5, asked 3×
- [Non-restoring division with flowchart](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_organization_and_architecture%3Anonrestoring-explain) — Computer Organization and Architecture, chapter 5, asked 3×

## Related in other subjects

- [Algorithm and flowchart for largest](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Aalgorithm-flowchart-largest-n) — Computer Programming, chapter 2
- [Algorithm and flowchart: quadratic roots](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Aalgo-flowchart-quadratic) — Computer Programming, chapter 2
- [Algorithm and flowchart: distance between points](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Aalgo-flowchart-distance) — Computer Programming, chapter 2
- [Algorithm and flowchart help; Armstrong flowchart](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Aalgorithm-flowchart-armstrong) — Computer Programming, chapter 2
