 Representing and manipulating data in computers

Start this free course now. Just create an account and sign in. Enrol and complete the course for a free statement of participation or digital badge if available.

Free course

# 7.3.1 Finding the 2's complement

In Section 2.4 you saw how to find the 2's complement representation of any given positive or negative denary integer, but it is also useful to be able to find the additive inverse of a 2's complement integer without going into and out of denary. For instance, 1111 1100 (−4) is the additive inverse, or 2's complement, of 0000 0100 (+4), but how does one find the additive inverse without converting both binary integers to their denary equivalents?

The answer is that the additive inverse, or 2's complement, of any signed binary integer can be found by a two-step process: first find the complement (1's complement) of the given number and then add 1. 1's complement or complement means that all the 1s are changed to 0s and all the 0s to 1s.

An example should make this clear.

## Example 8

Find the 2's complement of the signed integer 0001 1011.

First find the complement of the given integer (change all the 1s to 0s and all the 0s to 1s), getting:

1110 0100

and then add 1 to get:

1110 0101

So the 2's complement of 0001 1011 is 1110 0101. (Check: the given integer is+27, and 1110 0101 is −27.)

## Activity 24 (Self assessment)

1. Write down the complement of 1010 0101.

2. Find the 2's complement of the signed integer 1011 0111. Check your answer by converting both integers to denary.

3. Find the additive inverse of the signed integer 0000 1111.

1. The complement of 1010 0101 has all the 1s changed to 0s and all the 0s changed to 1s. Hence the complement is 0101 1010.

2. The 2's complement is found by first finding the complement and then adding 1. So it is

0100 1000 + 0000 0001 = 0100 1001

0100 1001 is equal to 73 in denary and 1011 0111 is equal to (−128 + 55) = −73, which checks.

3. Additive inverse is just another name for 2's complement, so the method is as above, giving:

1111 0000 + 0000 0001 = 1111 0001