Home » Digital Electronics

r's and (r-1)'s Complement of Numbers

Here, we are going to learn about the r's compliment and (r-1)'s compliment of the numbers with examples.
Submitted by Saurabh Gupta, on October 24, 2019

For a number system having its base/radix as r, we can define two types of complement for the corresponding number system which are as follows:

1) (r-1)'s complement

The (r-1)'s complement of a number in any number system with base r can be found out by subtracting every single digit of a number by r-1.

For Example: In the binary number system, the base is 2. Hence, its (r-1)'s i.e., (2-1 =1)'s complement can be obtained by subtracting each bit from 1, i.e., 1's complement for 001 can also be calculated by subtracting 001 from 111 which will be (111-001) = (110)2.

Similarly, in the octal number system, the base is 8 so its 7's complement can be calculated by subtracting each bit by 7, i.e., 7's complement for 347 in octal number system can be calculated by subtracting 347 from 777 which will yield (777 – 347) = (430)8.

2) r's complement

The r's complement of a non-zero number in any number system with base r can be calculated by adding 1 to the LSB of its (r-1)'s complement.

For Example: In binary number system, 2's complement of 001 can be calculated by adding 1 to the LSB of its 1'complement (i.e., 110 + 1) = (111)2.

Similarly, in octal number system, 8's complement of 347 can be calculated by adding 1 to the LSB of its 7'complement (i.e., 430 + 1) = (431)8.

9's and 10's complement in Decimal Number System

We already know that the decimal number system has its base as 10, As we have already discussed above, 9's complement of decimal number can be found out by subtracting its each by 9.

Example 1: Calculate 9's complement of (2457)10

Solution: 9999 – 2457 = (7542)10

Now, 10's complement of a decimal number can be calculated by adding 1 to the LSB of the 9's complement.


Example 2: Calculate 10's complement of (2457)10

Solution: 10's complement for (2457)10 is calculated by adding 1 to (7542)10 which is the 9's complement. Therefore, 10's complement of (2457)10 is (7543)10.






Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.