Representing and manipulating data in computers
Representing and manipulating data in computers

This free course is available to start right now. Review the full course description and key learning outcomes and create an account and enrol if you want a free statement of participation.

Free course

Representing and manipulating data in computers

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.

Answer

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.

Answer

  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

T224_2

Take your learning further

Making the decision to study can be a big step, which is why you'll want a trusted University. The Open University has 50 years’ experience delivering flexible learning and 170,000 students are studying with us right now. Take a look at all Open University courses.

If you are new to university level study, find out more about the types of qualifications we offer, including our entry level Access courses and Certificates.

Not ready for University study then browse over 900 free courses on OpenLearn and sign up to our newsletter to hear about new free courses as they are released.

Every year, thousands of students decide to study with The Open University. With over 120 qualifications, we’ve got the right course for you.

Request an Open University prospectus