## EXAMPLE FOR WEEK 21

The following example is related to the work covered in WEEK 21.

The question was:-Example for next week, what modifications would have to be made to make a four bit "subtract" circuit?

The method of subtraction in digital terms involves taking the "two's complement" of the term to be subtracted and ADDING it to the other term. The first thing we require is the definition of "two's complement". A "ones complement is just "invert all bits in the number, so 6 which is "0110" will have a "ones complement of "1001".

A "two's complement" is formed by adding 1 to the "one's complement, so 6 which is "0110" will have a "two's complement of "1001" + 1 = "1010"

ARITHMETIC EXAMPLE:

```              9 -         1001-
4           0100
---         ------
5           ????

First take the ones complement of 4, this will be 1011, then ADD 1. This will give 1100.
So the "two's complement" of 0100 is 1100. This is then ADDED to 9 to give out answer.

9 -         1001 +
4           1100
---          ----
5  (Carry 1)0101

```
In circuit terms a "one's complement means inverting each of the bits of the second number, ADDING it to the first + 1. With a 4 bit full adder we can invert all the B inputs and make the first "CARRY IN" permanently '1' adding the extra one as required.

The circuit to implement the above looks like this.