Code360 powered by Coding Ninjas X Code360 powered by Coding Ninjas X
Table of contents
1’s complement
2’s complement
Key Takeaways
Last Updated: Mar 27, 2024


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


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



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 .



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



  • 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 or r’s complement

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.



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.




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

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++ 


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..

Recommended Reading: Data Warehouse Architecture

Side by side, you can also practice a wide variety of coding questions commonly asked in interviews in Coding Ninjas Studio. Along with coding questions, you can also find the interview experience of scholars working in renowned product-based companies here. 


Happy learning!


Previous article
Different Number Systems and their Interconversion
Next article
What is Checksum
Live masterclass