1.
Introduction
2.
Complements
3.
1â€™s complement
4.
2â€™s complement
5.
FAQs
6.
Key Takeaways
Last Updated: Mar 27, 2024

Complements

Malay Gain
0 upvote
Master Python: Predicting weather forecasts
Speaker
Ashwin Goyal
Product Manager @

Introduction

Complements are used in digital computers for simplifying the manipulation of logical operations. Subtraction operation in binary can be simplified by using complements as signed binary numbers can be expressed using the complement.

Here, we will describe basic concepts of complements and its types.

Recommended Topic, Microinstruction in Computer Architecture and Difference Between Jfet and Mosfet

Complements

There are two types of complements for each r-based number system. These are the radix complement and diminished radix complement.

Letâ€™s discuss each type of complement with examples.

Diminished Radix Complement or (r-1)â€™s complement

This complement is defined as if there is a number N in base r having n digits, the

Diminished Radix Complement or (r-1)â€™s complement of N is (r^n - 1) - N .

Example

So for a 6-digit decimal number( base 10) N, Diminished Radix Complement or (r-1)=9â€™s complement is (10^6 - 1) - N = 999999 - N

For, a 6-digit binary number N, (2-1)= 1â€™s complement is  (2^6 - 1) - N = 111111 - N

So, 1â€™s complement of 101100 is (111111 - 101100) =010011

Also Read - Shift Registers in Digital Electronics

Characteristic

• While computing the Diminished Radix Complement, subtraction from (r^n - 1) will never require a borrow.

• This complement can be computed digit by digit.

Radix complement of an n-digit number N in base r is defined as (r^n - N) for N â‰  0 and as 0 for N = 0.

Example

So for a 6-digit decimal number( base 10) N, Radix Complement or r =10â€™s complement is (10^6 - N ).

For a 6-digit binary number N,  2â€™s complement is  (2^6  - N)

So, 2â€™s complement of 1101100  is 0010100.

Characteristic

râ€™s complement can be obtained by adding 1 to the (r-1)â€™s complement as

(r^n - N) =[ (r^n - 1) - N ] +1

Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

1â€™s complement

For binary numbers, 1â€™s complement can be expressed as Diminished Radix Complement as the base is 2.

For binary numbers we can easily compute its 1â€™s complement without following the steps of Diminished Radix Complement.

Step1: replace all 0â€™s by 1â€™s

Step 2: replace all 1â€™s by 0â€™s

For example, 1â€™s complement of (1101100)2 is (0010011)2 .

2â€™s complement

For binary numbers, 2â€™s complement can be expressed as Radix Complement for binary numbers as the base is 2.

For binary numbers, we can easily compute its 2â€™s complement without following the steps of Radix Complement.

Step1: Compute 1â€™s complement the binary number.

Step2: add 1 to the 1â€™s complement.

For example, 2â€™s complement of (1101100)2 is (0010011)2  + 1 = (0010100)2 .

Must read decimal to binary c++

FAQs

Q1. What is 9â€™s complement?

The 9â€™s complement of a decimal digit is the number that must be added to it to generate 9 i.e., the complement of 6 is 3 while the complement of 4 is 5 etc.

Q2. State shortcut method of computing 9â€™s complement for an n-digit number.

A quick technique to find the 9â€™s complement of a larger (n-digit) number is to replace each digit in the number by its 9â€™s complement.

Key Takeaways

This article covered different types of compliments describing the computation process of each type.

Check out the Coding Ninjas Studio library for getting a better hold of the data structures & algorithms and core CS subjects like Database Management SystemOperating system..