### Complement and its types. Two types are 1's complement and 2's complement. Complement Complement types Two types- 1's complem...

**Complement**and its types. Two types are 1's complement and 2's complement.

## Complement

### Complement types

Two types-- 1's complement
- 2's complement

#### 1's Complement

In a binary number changing all the zeros to ones and all the ones to zeros, we will get a number that is called 1's

**Complement**.That means,

If we replace 1 instead of 0 and 0 instead of 1 in a binary number then we will get 1' s Complement.

101011 ← Given Binary number

↓↓↓↓↓↓

010100 ←1's Complement

**2's Complement**

If we add 1 with the 1's Complement of a binary number then we will get a number. That is 2's Complement number.

Here, if we add 1 with this 1's Complement number then we will get 2's Complement.

101011 ← Given Binary number010100 ← 1's Complement

+ 1

ㅡㅡㅡ

010101 ← 2's Complement

#### Importance of 2's Complement

- The subtraction process can be completed by using additive processes.
- A simple logical circuit building becomes easier.
- By using this addition and subtraction process can be completed by the circuit.

Read about different types of codes in the number system.

Example: What will be the 2's complement of -209?

Solution:

Binary of +209 = 11010001

[

**If we see here is less than 8 bit then we have to add Zeros in left. In this case, we don't need it.**]Now,

For +209

1 1 0 1 0 0 0 1(Real value)

↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓

0 0 1 0 1 1 1 0(1's complement)

+ 1

ㅡㅡㅡㅡㅡㅡ

0 0 1 0 1 1 1 1(2's complement)

#### Subtraction using 2's complement

By 2's complementary addition process we can do subtraction. Here

**from which number we are subtracting**is called**partitive**and**which number we are subtracting from that number**is called**minus**.We have to take these steps for finding the subtraction -

- We have to add Zeros making the number 8 bit for the 8-bit register subtraction of both numbers.
- We have to find the 2's complement of the 2nd number(minus).
- Then we have to add this number with the first number as like binary addition process.
- Extra carry of sign bit will not be considered. That mean we have to skip the extra bit.

Example: Subtract (1101101)₂ from (110110₂) by using the method of 2's complement.

Solution:

Here ,

1st number(Partitive) = 01101101

2nd number (Minus) = 00110110

Now from 2nd number,

0 0 1 1 0 1 1 0 (Real value)

↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓

1 1 0 0 1 0 0 1 (1's complement)

+ 1

ㅡㅡㅡㅡㅡㅡ

1 1 0 0 1 0 1 0 (2's complement)

0 1 1 0 1 1 0 1 = 0 1 1 0 1 1 0 1

0 0 1 1 0 1 1 0 = 1 1 0 0 1 0 1 0 [2's complement]

ーーーーーーーーーーーーーー

**1**0 0 1 1 0 1 1 1 [After adding]

↗️

## No comments