Skip to main content

Complement of a Number

Subtraction of Binary Numbers  ; Octal and Hexadecimal Number  ; Convert Decimal to Binary

Complements

Complements are used in digital computers for simplifying the subtraction operation and for logical manipulations. There are two types of complements for each base-r system: (1) the r’s complement and (2) the (r-1)’s complement. When the value of the base is substituted, the two types receive the names 2’s and 1’s complement for binary numbers,  10’s and 9’s complement for decimal numbers.


The r’s Complement

Given a positive number N in base r with an integer part of n digits, the r’s complement of N is defined as rn  - N for N is not equal to 0 and 0 for N = 0. The following numerical example will help clarify the definition.

The 10’s complement of (52520)10 is 105 – 52520 = 47480

The number of digits in the number is n= 5

The 10’s complement of (0.3267)10 is 1 – 0.3267 = 0.6733

No integer part, so 10n = 100 = 1

The 10’s complement of (25.639)10 is 102 – 25.639 = 74.361.

The 2’s complement of (101100)2 is 26 – (101100)2 = (1000000 - 101100)2 = 010100

The 2’s complement of (0.0110)2 is (1 – 0.0110)2 = 0.1010

From the definition and the examples, it is clear that the 10’s complement of a decimal number can be formed by leaving all least significant zeros unchanged, subtracting the first nonzero least significant digit from 10, and then subtracting all other higher significant digits from9. The 2’s complement can be formed by leaving all least significant zeros and the first nonzero digits unchanged, and then replacing 1’s by 0’s and 0’s by 1’s in all other higher significant digits. A third simpler method for obtaining the r’s complement is given after the definition of the (r-1)’s complement.

                The examples listed here use numbers with r = 10(for decimal) and r = 2(for binary) because these are the two bases of most interest to us.

 

The (r - 1)’s Complement

Given a positive number N in base r with an integer part of n digits and a fraction part of m digits, the (r - 1)’s complement of N is defined as rm – r-m – N. Some numerical examples follow:

The 9’s complement of (52520)10 is (105 – 1 - 52520) = 99999 – 52520 = 47479

No fraction part, so 10-m = 100 = 1

The 9’s complement of (0.3267)10 is (1 – 10-4 – 0.3267) = 0.9999 – 0.3267 = 0.6732

No integer part, so 10n = 100 = 1

The 9’s complement of (25.639)10 is (102 – 10-3 – 25.639) = 99.999 – 25.639 = 74.360

The 1’s complement of (101100)2 is (26 - 1) – (101100) = (111111 - 101101)2 = 010011

The 1’s complement of (0.0110)2 is (1 – 2-4) – (0.0110) = (0.1111 – 0.0110)2 = 0.1001

From the examples, we see that the 9’s complement of a decimal number is formed simply by subtracting every digit by 9. The 1’s complement of a binary number is even simpler to form: the 1’s are changed to 0’s and 0’s are changed to 1’s. Since the (r - 1)’s complement is very easily obtained, it is sometimes convenient to use it when the r’s complement is desired. From the definitions and from a comparison of the results obtained in the examples, it follows that the r’s complement can be obtained from the (r - 1)’s complement after the addition of r-m to the least significant digit. For example, the 2’s complement of 10110100 is obtained from the 1’s complement 01001011 by adding 1 to give 01001100.

Short Trick to find 1’s and 2’s complement in Binary

1’s complement – Replace 0 by 1 and 1 by 0

2’s complement – Add 1 after replacing 0 by 1 and 1 by 0

 

     

 

 


Comments

Popular posts from this blog

Rules of divisibility part -1

Rules of divisibility In Vedic mathematics, it can be determined whether any part of any other number can be given completely without dividing it by several methods. These methods are based on the law of divisibility. By using these rules, calculations related to factors, parts etc. are simplified. Law of divisibility by number 2 :- If unit digit of given number is divisible by 2 then the given number is divisible by 2 also.                                                                 or  If unit digit of given number is 0,2,4,6 or 8 , then given number is divisible by 2. Example :- 10 ,32 ,74 ,108 ,2058 etc. Law of divisibility by number 3 :- If the sum of digits of given number is divisible by 3, then the number is divisible by 3 also. Illustration 1:-  In 546532 sum of digits=5+4+6+5+3+2=25 25 is not divisible...

Octal and Hexadecimal Number

Complement of a Number    Types of Number system    Convert Decimal to Binary If you are new to this article, I strongly recommend to read our previous article before preceding this. In our previous article, we had already seen that binary number has a base of 2. It means that binary number contains 2 1 = 2 combinations which are 0 and 1. Similarly, Octal and Hexadecimal number has a fixed number of combinations. As we earlier know that octal has a base 8, then it contains 8 digits through 0 to 7 which means 2 3 =8 combinations and Hexadecimal has a base 16 which means it has 2 4 =16 combinations.                 If you are focusing on a sequence i.e. octal, hexadecimal. They are the combinations of increasing power of 2. Octal – 2 3 , Hexadecimal - 2 4 This power indicates how many bits are in a number for a particular number system Octal has 3 bits Hexadecimal has 4 bits T...

mathematics skills

Are you ready to give your mathematics skills a boost? These simple math tricks can help you perform calculations more quickly and easily. They also come in handy if you want to impress your teacher, parents, or friends. 01 The Answer Is 2 Think of a number. Multiply it by 3. Add 6. Divide this number by 3. Subtract the number from Step 1 from the answer in Step 4. The answer is 2. Same Three-Digit Number Think of any three-digit number in which each of the digits is the same. Examples include 333, 666, 777, and 999. Add up the digits. Divide  the three-digit number by the answer in Step 2. The answer is 37. Six Digits Become Three Take any three-digit number and write it twice to make a six-digit number. Examples include 371371 or 552552. Divide the number by 7. Divide it by 11. Divide it by 13. The order in which you do the division is unimportant! The answer is the three-digit number. Examples: 371371 gives you 371 or 552552 gives you 552. A related trick is to take any three-di...