What is the purpose of Complements in Computer Architecture?


Complements are used in digital computers for facilitating the subtraction operation and for logical manipulation. There are two methods of complements for each base r system: the r's complement and the (r - 1)'s complement.

(r - 1)'s Complement

9's complement

Given a number N in base r having n digits, the (rn - 1)'s complement of N is represented as (rn- 1) - N. For decimal numbers r = 10 and r - 1 = 9, therefore the 9's complement of N is (10n - 1) - N.

Now, 10n defines a number that includes a single 1 followed by n 0's. 10n – 1 is a number defined by n 9's. For example, with n = 4 we have 104 = 10000 and 104 - 1 = 9999. It follows that the 9's complement of a decimal number is acquired by subtracting each digit from 9. For example, the 9's complement of 546700 is 999999 - 546700 = 453299 and the 9's complement of 12389 is 99999 - 12389 = 876I0.

1's complement

For binary numbers, r = 2 and r - 1 = 1, so the 1's complement of N is (2n - 1) - N. 2n is described by a binary number that includes a 1 followed by n 0's. 2n - 1 is a binary number defined by n 1's. For example, with n = 4, we have 24 = (10000)2, and 24 - 1 = (1111)2. Hence the 1's complement of a binary number is acquired by subtracting each digit from 1. The subtraction of a binary digit from 1 creates the bit to change from 0 to 1 or from 1 to 0. Hence, the 1's complement of a binary number is structured by modifying 1's into 0's and 0's into 1's. For example, the 1's complement of 1011001 is 0100110 and the 1's complement of 0001111 is 1110000.

The (r - 1)'s complement of octal or hexadecimal numbers is obtained by subtracting each digit from 7 or F (decimal 15) respectively.

(r's) Complement

10's complement

The r's complement of an n-digit number N in base r is represented as rn - N for N 0 and 0 for N = 0. Contrasting with the (r - 1)'s complement, we see that the r's complement is acquired by inserting 1 to the (r - 1)'s complement because rn - N = [(rn - 1) - N] + 1.

Therefore, the 10's complement of the decimal 2389 is 7610 + 1 = 7611 and is acquired by inserting 1 to the 9's complement value. The 2's complement of binary 101100 is 010011 + 1 = 010100 and is acquired by inserting 1 to the 1's complement value.

2's complement

The 2's complement can be produced by leaving all least significant 0's and the first 1 unaltered and then restoring 1's by 0's and 0's by 1’s in all other larger significant bits. The 2's complement of 1101100 is 0010100 and is acquired by leaving the two low-order 0's and the first 1 unaltered, and then restoring 1's by 0's and 0's by 1's in the other four most significant bits.

Updated on: 24-Jul-2021

6K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements