- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# 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 (r^{n} - 1)'s complement of N is represented as (r^{n}- 1) - N. For decimal numbers r = 10 and r - 1 = 9, therefore the 9's complement of N is (10^{n} - 1) - N.

Now, 10^{n} defines a number that includes a single 1 followed by n 0's. 10^{n} – 1 is a number defined by n 9's. For example, with n = 4 we have 10^{4} = 10000 and 10^{4} - 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 (2^{n} - 1) - N. 2^{n} is described by a binary number that includes a 1 followed by n 0's. 2^{n} - 1 is a binary number defined by n 1's. For example, with n = 4, we have 2^{4} = (10000)_{2}, and 2^{4} - 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 r^{n} - 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 r^{n} - N = [(r^{n} - 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.

- Related Articles
- What is the Evolution of Computer Architecture?
- What is computer architecture?
- What is the structure of Pipelining in Computer Architecture?
- What is the Format of Microinstruction in Computer Architecture?
- What is Pipelining in Computer Architecture?
- What is Latches in Computer Architecture?
- What is Hector in Computer Architecture?
- What is Computer Network Architecture?
- What is the layout of Pipelined Instruction in computer architecture?
- What is the implementation of FX Pipelines in Computer Architecture?
- What is the structure of Wisconsin Multicube in computer architecture?
- What is the configuration of memory subsystem in computer architecture?
- What is the division of binary numbers in Computer Architecture?
- What is the difference between Computer Architecture and Computer Organization?
- What is Flynn’s Taxonomy in Computer Architecture?