Division

  • Division can be re-expressed as repeated subtraction:
  • To divide 21 by 7 see how many times you can subtract 7 from 21.
  • Of course, this is the same as adding -7, so we use two's complement notation.

21 is represented as 010101

7 is 000111, so -7 is 111001

0 1 0 1 0 1

+ 1 1 1 0 0 1

(1) 0 0 1 1 1 0

+ 1 1 1 0 0 1

(10) 0 0 0 1 1 1

+ 1 1 1 0 0 1

(11) 0 0 0 0 0 0

Since we're using 6 bit patterns the extra carry bits would normally be discarded, but notice that they contain the integer part of the answer.

The 6 bits to their right contain the remainder.

So 21 divided by 7 is 3, with 0 remainder.