Binary subtraction

Subtract these binary numbers: 0 - 0

The answer will be in signed binary (two's complement).

1286432168421
00000000
- 00000000

Binary subtraction can be performed using two's complement addition:

  1. Convert the number being subtracted to two's complement (flip bits and add 1)
  2. Add the two numbers together using binary addition
  3. The result is in two's complement form

Example: Calculate 01010000 - 00001100

Step 1: Convert 00001100 to two's complement
        Flip: 11110011
        Add 1: 11110100
Step 2: Add 01010000 + 11110100 = 01000100
Result: 01000100 (68 in denary)

Binary subtraction is typically performed using two's complement addition, which is how computers actually perform subtraction.

Method: Two's Complement Addition

To calculate A - B:

  1. Keep A as it is
  2. Convert B to its two's complement:
    • Flip all the bits in B (0 becomes 1, 1 becomes 0)
    • Add 1 to the result
  3. Add A and the two's complement of B using binary addition
  4. Ignore any carry bit that extends beyond 8 bits
  5. The result is in two's complement form
Example: 80 - 12
A = 80 = 01010000
B = 12 = 00001100

Step 1: Convert B to two's complement
  Flip bits: 11110011
  Add 1:     11110100

Step 2: Add A + (-B)
  01010000
+ 11110100
-----------
 101000100  (ignore the leftmost 1 as it's the 9th bit)
  01000100 = 68 in denary
Why This Works

Two's complement represents negative numbers in binary. When you convert B to two's complement, you're effectively creating -B. Then A + (-B) = A - B.

References:

  • Wikibooks Computer Science A level (subtraction): AQA
  • BBC Bitesize GCSE (two's complement): Edexcel