In the above formulas,
These are the following advantages of using r's complement:
Let's take some examples to understand how we can calculate the r's and (r-1)'s complement of binary, decimal, octal, and hexadecimal numbers.
Example 1: (1011000)2
This number has a base of 2, which means it is a binary number. So, for the binary numbers, the value of r is 2, and r-1 is 2-1=1. So, we can calculate the 1's and 2's complement of the number.
1's complement of the number 1011000 is calculated as:
= {(27 )10-1}-(1011000)2
= {(128)10-1}-(1011000)2
= {(127)10}-(1011000)2
= 11111112 - 10110002
= 0100111
2's complement of the number 1011000 is calculated as:
= (27 )10 - (1011000)2
= (128)10 - (1011000)2
= 100000002 - 10110002
= 01010002
Example 2: (155)10
This number has a base of 10, which means it is a decimal number. So, for the decimal numbers, the value of r is 10, and r-1 is 10-1=9. So, we can calculate the 10's and 9's complement of the number.
9's complement of the number 155 is calculated as:
= {(103)10-1}-(155)10
= (1000-1)-155
= 999-155
= (844)10
10's complement of the number 1011000 is calculated as:
= (103)10 - (155)10
= 1000 - 155
= (845)10
Example 3: (172)8
This number has a base of 8, which means it is an octal number. So, for the octal numbers, the value of r is 8, and r-1 is 8-1=7. So, we can calculate the 8's and 7's complement of the number.
7's complement of the number 172 is calculated as:
= {(83)10 - 1} - (172)8
= ((512)10 - 1) - (132)8
= (511)10 - (122)10
= (389)10
= (605)8
8's complement of the number 172 is calculated as:
= (83)10-(172)8
= (512)10 - 1728
= 51210 - 12210
= 39010
= 6068
Example 4: (F9)16
This number has a base of 16, which means it is a hexadecimal number. So, for the hexadecimal numbers, the value of r is 16, and r-1 is 16-1=15. So, we can calculate the 16's and 15's complement of the number.
15's complement of the number F9 is calculated as:
{(162)10 - 1}-(F9)16
(256-1)10-F916
25510 - 24910
(6)10
(6)16
16's complement of the number F9 is calculated as:
{(162 )10} - (F9)16
25610 - 24910
(7)10
(7)16
6 videos|76 docs|52 tests
|
|
Explore Courses for Electronics and Communication Engineering (ECE) exam
|