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

WORLD  HERITAGE  SITES IN  INDIA PART- 1  Why did UNESCO start the World Heritage Centre? The UNESCO World Heritage Centre was born by merging two separate movements. The first was a movement for the preservation of cultural sites. The second was a movement that dealt with the conservation of nature. The ball for the first movement was set rolling with the decision to build the Aswan High Dam in Egypt. This dam would have flooded the valley in which one of the treasures of ancient Egypt- the Abu Simbel temple- wsa located. In 1959 UNESCO launched a campaign to safeguard these temples. It was a joint effort of 50 countries, and it led to many other similar projects to safeguard rare treasures. It was the United States that led the movement to combine the conservation of natural wonders along with cultural sites.  World Heritage Fund- If 1972, the World Heritage Fund was created. Its aim is to assist nations in identifying, preserving, and promoting World Heritage...

Square of the number

     This article is used to find out the square of  a number in a short period of time compare to normal maths. It increase the speed of your calculations.  The answer obtained by multiplying a number by itself is the square of that number. Example :- 6×6= 36 which is the square of 6.                          8×8= 64 which is the square of 8.      1.   Square of numbers ending in 5 :- Example 1-: 35 2 =   ? Step 1:- Multiply the first part by the first part plus 1: 3 ×(3+1) =3×4 =12 Step 2:- Write the number 25 next to the result from step 1: 35 2 = 12_25 = 1225 Example 2-: (in 3 digits) 125 2 =   ? Step 1:- Multiply the first part by the first part plus 1: 12 ×(12+1) =12×13 =156 Step 2:- Write the number 25 next to the result from step 1: 125 2 = 156_25 = 15625 Example 3-: (in decimal numbers) 9.5 2 =     ? Step 1:- M...

What is Genetics

What is Genetics?     Have you ever wondered why some people are short while others are tall, or why some have brown eyes while others have black eyes? Genetics is the study of the ways in which different characteristics are passed from each generations of living things to the next. Genetics has many divisions like population genetics and epigenetics   What is DNA?     Each of us has a unique set of chemical blueprints that determine how our body looks and functions. These blueprints are contained in our DNA, which is the short form of deoxyribonucleic acid.    DNA is in the form of long spiral-shaped molecules found inside every cell. The instructions for constructing and maintaining cells are built into this molecule. DNA can copy itself so that all the new cells produced by a plant or animal, contain copies of the same set of genetic instructions, or genetic code. Every single living organism processes DNA. In fact, DNA defin...