One of the most common methods of number representation used in digital systems is the binary number system. There are just two variables or digit values available in the binary system: 0 (off) and 1 (on). represented by any object with only two conceivable operational states.

There are typically two different sorts of compliments for binary numbers: the complement of 1 and the complement of 2. Simply inverting the provided integer to obtain a binary number refers to the complement of 1.

For example, 001101 is the one’s complement of binary number 110010. While adding 1 in the least significant bit of the 1’s complement, it refers to the two’s complement. For example, (01101) + 1 = 01110 is the two’s complement of binary integer 10010.

**What is a two’s (2’s) complement?**

The 2’s complement of a binary integer may be created using a straightforward technique. Simply invert the provided number and add 1 to the least significant bit (LSB) of the output to obtain a binary integer’s 2’s complement.

**Examples of two’s (2’s) complement**

We have explained the concept of 2^{’}s complement with the help of some examples.

**Example 1:**

Find the 2s complement if the decimal value is 17 and the number of bits is 16.

**Solution:**

Number in decimal = 17

**Step 1:** First, convert 17 to binary:

2 | 17 |

2 | 8 – 1 |

2 | 4 – 0 |

2 | 2 – 0 |

1 – 0 |

Binary of 17 = 10001

Selected Bits = 16

Binary Number after completing bits = 0000 0000 0001 0001

**Step 2: **Taking One’s complement of the binary number:

Write down the binary Number

0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 |

Invert all values (Swap each 0 with 1 and each 1 with 0):

0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 |

1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 1 | 1 | 0 |

**Step 3: **Taking Two’s complement by adding 1 in the previous binary number:

1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 1 | 1 | 0 |

+ | 1 | ||||||||||||||

1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 1 | 1 | 1 |

Number in 2’s complement with 16-bit representation

Decimal | 17 |

Binary | 0000 0000 0001 0001 |

2’s Complement | 1111 1111 1110 1111 |

The above example can also be solved by using a two’s complement calculator to perform the conversions within seconds. The calculation explains the step-by-step solutions to the problems.

To calculate the answer, we have to follow the steps:

- First, select the type of input data with respect to the base.
- Enter the number of bits.
- Enter the value
- Press the calculate button.

**Example 2:**

Find the 2s complement if the decimal value is 172 and the number of bits is 20.

**Solution:**

Number in decimal = 172

**Step 1:** First, convert 172 to binary:

2 | 172 |

2 | 86 – 0 |

2 | 43 – 0 |

2 | 21 – 1 |

2 | 10 – 1 |

2 | 5 – 0 |

2 | 2 – 1 |

1 – 0 |

Binary of 172 = 10101100

Selected Bits = 20

Binary Number after completing bits = 0000 0000 0000 1010 1100

**Step 1:**

Taking One’s complement of the binary number:

Write down the binary Number

0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 1 | 0 | 0 |

Invert all values (Swap each 0 with 1 and each 1 with 0):

0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 1 | 0 | 0 |

1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | 1 |

**Step 2:**

Taking Two’s complement by adding 1 in the previous binary number:

1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | 1 |

+ | 1 | ||||||||||||||||||

1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 |

Number in 2’s complement with 16-bit representation

Decimal | 17 |

Binary | 10101100 |

2’s Complement | 1111 1111 1111 0101 0100 |

**Uses for Binary 2’s Complement Numbers**

The 2’s complement of a binary integer is used for a variety of purposes, primarily in signed binary number encoding and different arithmetic operations for binary numbers, such as additions and subtractions. It is highly helpful in computer number representation since the 2’s complement form is unambiguous.

**Summary:**

In the above article, we have learned the basic definition, method, and examples of two’s (2’s) complement. Now you will solve any problems of two’s (2’s) complement relative very easily and it enhances your interest in two’s (2’s) complement.