• Practice
  • About 14 min
  • 5 practice questions

Subtraction by complements: step-by-step problems

Subtract binary numbers by adding the one's complement with end-around carry or the two's complement, and recognise a negative result.

If something looks wrong, please tell us.

Computers rarely have a separate circuit for subtraction. They add the complement of the number being subtracted. Exams test this procedure directly, usually with 4-bit or 8-bit numbers. Knowing the steps exactly, and what a missing carry means, is what earns the marks.

One's complement method (A minus B)

  • Write both numbers with the same number of bits.
  • Find the one's complement of B by flipping every bit.
  • Add it to A.
  • If there is a carry out of the leftmost bit, remove it and add 1 to the result (the end-around carry). The answer is positive.
  • If there is no carry, the answer is negative: take the one's complement of the sum and put a minus sign in front.

Two's complement method (A minus B)

  • Find the two's complement of B: flip all bits and add 1.
  • Add it to A.
  • If there is a carry out of the leftmost bit, discard it. The remaining bits are the positive answer.
  • If there is no carry, the answer is negative: take the two's complement of the sum to get the size of the answer.

Worked examples

Example 1. Compute 1101 minus 0110 (13 minus 6) by one's complement. The one's complement of 0110 is 1001. Add: 1101 + 1001 = 10110. There is a carry, so drop it, leaving 0110, and add 1: 0111. The answer is 0111 = 7, which equals 13 minus 6.

Example 2. Compute 1101 minus 0110 by two's complement. The two's complement of 0110 is 1001 + 1 = 1010. Add: 1101 + 1010 = 10111. Discard the carry: 0111 = 7. Both methods agree.

Example 3. Compute 0101 minus 1001 (5 minus 9). The two's complement of 1001 is 0110 + 1 = 0111. Add: 0101 + 0111 = 1100. There is no carry, so the answer is negative. Its size is the two's complement of 1100, which is 0011 + 1 = 0100 = 4. The result is minus 4, as 5 minus 9 should be.

Example 4. Check Example 3 with one's complement. The one's complement of 1001 is 0110. Add: 0101 + 0110 = 1011. There is no carry, so the answer is negative. The one's complement of 1011 is 0100 = 4. The result is minus 4 again.

Why it works. In 4 bits there are 16 patterns. Adding the two's complement of B is the same as adding 16 minus B, so A + (16 minus B) equals A minus B plus 16. The extra 16 appears as the carry out of the leftmost bit, which is exactly the part that is discarded. When A is smaller than B the sum stays below 16, so there is no carry and the pattern left behind is the complement of the negative answer.

Carry out means a positive answer. No carry out means a negative answer, still in complement form.

Common mistakes

  • Forgetting to give both numbers the same width before complementing.
  • Adding 1 in the one's complement method before the carry has been checked. The 1 is added only for the end-around carry.
  • Forgetting the extra step of re-complementing when there is no carry.
  • Treating the discarded carry as part of the answer in the two's complement method.

Key takeaways. Subtraction is addition of a complement. Look for the carry out: if present the answer is positive (discard it for two's complement, add it back for one's complement); if absent, complement the sum and attach a minus sign.

Check your understanding

  1. 1. What is the one's complement of 0110?

    1. 1001
    2. 1010
    3. 1000
    4. 0111
    Show answer

    Answer: A. Flip each bit: 0110 becomes 1001. Adding 1 would give the two's complement, 1010.

  2. 2. Using two's complement in 4 bits, what is 1101 minus 0110?

    1. 0110
    2. 0101
    3. 0111
    4. 1000
    Show answer

    Answer: C. The two's complement of 0110 is 1010. 1101 + 1010 = 10111; discard the carry to get 0111 = 7.

  3. 3. In two's complement subtraction, a missing carry out of the leftmost bit means the result is:

    1. Zero
    2. Positive
    3. Too large to store
    4. Negative
    Show answer

    Answer: D. No carry means A was smaller than B, so the answer is negative and the sum is its two's complement.

  4. 4. Using 4-bit two's complement working, what is 0101 minus 1001 (5 minus 9, unsigned values), as a decimal?

    1. -4
    2. 4
    3. -14
    4. 9
    Show answer

    Answer: A. The two's complement of 1001 is 0111. 0101 + 0111 = 1100 with no carry, so the answer is negative, size 0100 = 4. The result is minus 4.

  5. 5. In the one's complement method, what is the 'end-around carry'?

    1. A carry that is dropped
    2. A carry added back to the result
    3. A borrow taken from the next bit
    4. A final sign bit
    Show answer

    Answer: B. If the leftmost addition produces a carry, it is removed from the left and added to the right end of the result.

Privacy · Terms · Refunds · Delivery