In mathematics, two’s complement is written in the form of binary numbers like 0 and 1. Two’s complement is used to represent negative and positive numbers. You can also perform arithmetic operations on two or more two’s complements numbers.

In this article, we’ll learn the definition and conversion of decimal and binary numbers into two’s complements along with a lot of examples.

## What is two’s complement?

A mathematical operation on binary numbers and is an example of a radix complement is known as two’s complement. Signed number representation can be computed by using it.

To encode the negative and positive numbers in the form of 0 and 1, two’s complement is used. The decimal and binary numbers are easily converted into two’s complements. One’s complement is an alternate of binary numbers.

Adding one in the result one’s complement will give two’s complement. In simple words, invert all the binary numbers to take the form of one’s complement and then add one to the least significant bit to get the form of two’s complement.

# Conversion of binary numbers and decimals into two’s complement

Let’s discuss the conversion of binary and decimals into two’s complements.

### 1. Binary to two’s complement

Follow the below steps to convert a binary number into two’s complement.

- First of all, take a binary number.
- Now invert the digits of binary numbers by converting all the zeros into ones and ones into zeros. Or simply take the transpose of the binary numbers.
- Then add one to the right side of the inverted binary number. Or add one in the least significant bit at the right side of the number.

By following the above steps, you can easily convert binary numbers in the form of 2’s complement.

Following are a few examples of binary to two’s complement.

**Example 1**

Convert the given binary number into 2’s complement

1001101010

**Solution**

**Step 1:** Take the binary number.

1001101010

**Step 2:** Now Take the transpose of the above binary number.

0110010101

**Step 3:** Add 1 to the right side of the inverted binary number.

0 1 1 0 0 1 0 1 0 1

+ 1

0 1 1 0 0 1 0 1 1 0

Hence the 2’s complement of the given binary number is 0110010110.

**Example 2**

Convert the given binary number into 2’s complement

110001110

**Solution**

**Step 1:** Take the binary number.

110001110

**Step 2:** Now Take the transpose of the above binary number.

001110001

**Step 3:** Add 1 to the right side of the inverted binary number.

0 0 1 1 1 0 0 0 1

+ 1

0 0 1 1 1 0 0 1 0

Hence the 2’s complement of the given binary number is 1110010.

**Table of some binary numbers to two’s complement**

Binary numbers | Two’s complement |

00111011 | 11000101 |

10111010 | 01000110 |

11110000 | 00010000 |

10101010 | 01010110 |

11001100 | 00110100 |

00000001 | 11111111 |

11100010 | 00011110 |

00011100 | 11100100 |

### 2. Decimal to two’s complement

To convert the decimal number into two’s complement, follow the below steps.

- Take a positive decimal number.
- Convert the decimal number into a binary number.
- Now invert the digits of binary numbers by converting all the zeros into ones and ones into zeros. Or simply take the transpose of the binary numbers.
- Then add one to the right side of the inverted binary number. Or add one in the least significant bit at the right side of the number.
- In the case of a negative decimal number, calculate the number according to the positive integer by following the above steps and then repeat the steps to get the two’s complement of the negative integer.

By following the above steps, you can easily convert positive and negative decimal numbers in the form of 2’s complement.

Following are a few examples of decimal to two’s complement

**Example 1: For a positive integer**

Convert 54 into two’s complement.

**Solution**

**Step 1:** Convert the given positive integer into binary number.

2 | 54 |

2 | 27 – 0 |

2 | 13 – 1 |

2 | 6 – 1 |

2 | 3 – 0 |

2 | 1 – 1 |

Hence, the binary number of 54 is 110110.

**Step 2:** Now Take the transpose of the above binary number.

110110 becomes 001001 after transposing.

**Step 3:** Add 1 to the right side of the inverted binary number.

0 0 1 0 0 1

+ 1

0 0 1 0 1 0

Hence the two’s complement of 54 is 001010.

**Example 2: For a negative integer**

Convert -49 into two’s complement.

**Solution**

**Step 1:** First of all, convert the positive integer into binary number.

2 | 49 |

2 | 24 – 1 |

2 | 12 – 0 |

2 | 6 – 0 |

2 | 3 – 0 |

2 | 1 – 1 |

Hence, the binary number of 49 is 110001.

**Step 2:** Now Take the transpose of the above binary number.

110001 becomes 001110 after transposing.

**Step 3:** Add 1 to the right side of the inverted binary number.

0 0 1 1 1 0

+ 1

0 0 1 1 1 1

**Step 4:** Now repeat the process to get the result of -49. Take transpose of the above result of 49.

001111 becomes 110000 after transposing.

**Step 3:** Add 1 to the right side of the above number.

1 1 0 0 0 0

+ 1

1 1 0 0 0 1

Hence the 2’s complement of -49 is 110001.

You can also use a two’s complement calculator for the conversion of positive integers, negative integers, and binary numbers into two’s complement.

**Table of some decimal numbers to two’s complement**

Positive integer | 2’s complement | Negative integer | 2’s complement |

5 | 1111 1011 | -5 | 0000 0101 |

11 | 1111 0101 | -11 | 0000 1011 |

19 | 1110 1101 | -19 | 0001 0011 |

22 | 1110 1010 | -22 | 0001 0110 |

28 | 1110 0100 | -28 | 0001 1100 |

36 | 1101 1100 | -36 | 0010 0100 |

41 | 1101 0111 | -41 | 0010 1001 |

56 | 1100 1000 | -56 | 0011 1000 |

61 | 1100 0011 | -61 | 0011 1101 |

72 | 1011 1000 | -72 | 0100 1000 |

110 | 1001 0010 | -110 | 0110 1110 |

126 | 1000 0010 | -126 | 0111 1110 |

## Summary

Now you are witnessed that two’s complement is not a difficult topic. You can easily solve the conversion problems of two’s complement just by learning the methods of this post.