All subjects · Computer Science · WCP01 Principles of Computer Science

Binary addition, subtraction, overflow and underflow

Edexcel IAL Computer Science · WCP01 Principles of Computer Science

Binary is added column by column like denary, carrying 1 when a column reaches 2. Subtraction in two's complement is done by adding the negative. When a result does not fit, overflow occurs (spec points 2.2.1 and 2.2.3).

Practise this in the app: instant marking and a fix for every mistake. Free, no email needed to start.

Practise this lesson

Binary addition rules

Example (unsigned): 0110 1101 (109) + 0011 1010 (58) = 1010 0111 (167). Always show the carries in an exam.

Subtraction with two's complement

To work out A - B, find the two's complement of B (invert, add 1) and add it to A. Ignore any carry out of the MSB.

Example: -37 - 21 in 8 bits, worked as -37 + (-21): 1101 1011 + 1110 1011 = 1100 0110 with a carry out of 1, which is discarded. 1100 0110 = -58. Correct.

Overflow and underflow

Worked example

Calculate 45 - 19 using 8-bit two's complement.

  1. 45 = 0010 1101
  2. 19 = 0001 0011, so -19 = 1110 1101
  3. Add: 0010 1101 + 1110 1101 = 0001 1010, carry out 1 discarded

Answer: 0001 1010 = 26

Key idea: 1 + 1 = 10, 1 + 1 + 1 = 11. A - B = A + (two's complement of B), discard the carry out. Overflow: result too big in size (positive or negative); underflow: too close to zero to represent.

Check yourself

  1. Add the unsigned 8-bit numbers 0011 0110 and 0100 1011. Give the 8-bit result.
    Show answer

    10000001. 54 + 75 = 129 = 1000 0001.

  2. What is the denary value of 0101 1101 + 0010 0111 (unsigned)?
    Show answer

    132. 93 + 39 = 132.

  3. Calculate 30 - 47 using 8-bit two's complement. Give the 8-bit result.
    Show answer

    11101111. 30 = 0001 1110; -47 = 1101 0001; sum = 1110 1111 = -17.

  4. In 8-bit two's complement, 0101 1010 + 0011 0010 is calculated. What denary value does the 8-bit result appear to represent?
    Show answer

    -116. The sum pattern is 1000 1100, whose MSB is 1, so it reads as -116. 140 is out of range: overflow.

  5. Two positive two's complement numbers are added and the result has an MSB of 1. What has happened?
    • Underflow
    • Overflow
    • A correct negative result
    • A logical shift
    Show answer

    Overflow. Two positives cannot make a negative; the result was too large.

  6. When adding two unsigned 8-bit numbers, what shows that overflow has happened?
    • A 0 in the least significant bit
    • The result is even
    • The result has more 1s than 0s
    • A carry out of the most significant bit
    Show answer

    A carry out of the most significant bit. The ninth bit cannot be stored.

  7. Which is an example of underflow?
    • Adding 1 to 255 in an unsigned byte
    • A fractional result is so close to zero that it is stored as 0
    • Converting binary to hexadecimal
    • Shifting a pattern one place left
    Show answer

    A fractional result is so close to zero that it is stored as 0. Underflow: too small to represent. Adding 1 to 255 is overflow.

  8. Using 8-bit unsigned binary, what is the largest number that can be added to 200 without causing overflow?
    Show answer

    55. 200 + x must be at most 255, so x = 55.

Practise with instant feedback

Sources

Last updated 8 November 2026. Spotted a mistake? Tell us.