# Understanding Two’s Complement in Digital Systems

**Two’s Complement in Digital Systems:** In digital systems, the binary number system is used to represent numerical values.

However, there is a problem with the traditional binary representation of negative numbers, known as the signed-magnitude representation.

Two’s complement is a method of representing negative numbers in binary that overcomes this problem. In this article, we will discuss the concept of two’s complement, how it works, and its advantages over other methods of representing negative numbers in digital systems.

**What is Two’s Complement?**

Two’s complement is a method of representing negative numbers in binary. It is based on the idea that the leftmost bit of a binary number, known as the sign bit, is used to indicate whether the number is positive or negative.

In two’s complement, a positive number is represented in the same way as it would be in the traditional binary representation. However, a negative number is represented by the two’s complement of its absolute value.

**For example**: Consider the number “-5”.

In the traditional binary representation, it would be represented as 1001. However, in two’s complement, it is represented as the two’s complement of its absolute value, which is 1011. The two’s complement of a binary number is found by inverting all the bits and adding 1 to the result.

**How Two’s Complement Works**

The key feature of two’s complement is that it allows for the efficient representation of negative numbers in binary.

It does this by utilizing the concept of overflow. In a digital system, overflow occurs when a number exceeds the maximum value that can be represented in a given number of bits. In two’s complement, overflow is used to represent negative numbers.

When a positive number is added to a negative number, the result is a negative number. However, in two’s complement, the result is represented as an overflow. This is because the addition of a positive number to a negative number results in a number that exceeds the maximum positive value that can be represented in the given number of bits.

**For example**: Consider the **8-bit** numbers “01010101 (85)” and “11101010 (-22)”.

If we add these two numbers together using two’s complement, the result is 10011011. However, this result exceeds the maximum positive value that can be represented in 8 bits, which is 01111111 (127).

Therefore, the result is considered an overflow and is interpreted as the two’s complement of the actual result, which is -43.

**Advantages of Two’s Complement: **

There are several advantages of using two’s complement to represent negative numbers in digital systems.

- One of the main advantages is that it allows for the efficient representation of negative numbers. This is because it utilizes the concept of overflow to represent negative numbers, which eliminates the need for separate representations of positive and negative numbers.
- Another advantage of two’s complement is that it allows for the efficient implementation of arithmetic operations such as addition and subtraction. This is because the same operations can be used for both positive and negative numbers.

Additionally, the overflow that occurs when a positive number is added to a negative number is automatically handled by the system, which eliminates the need for separate overflow detection and handling.

**Examples: **

In this section, we’ll discuss the steps of finding the two’s complements of a given decimal number.

**Example 1:**

Evaluate the two’s complement of **“30”.**

**Solution:**

**Step 1:**

The first step is to convert the given decimal number into the binary number system. Now there’s a question why do we have to convert it first? The answer is we can take the two’s complement only of the binary numbers.

2 | 30 |

2 | 15 – 0 |

2 | 7 – 1 |

2 | 3 – 1 |

1 – 1 |

When the conversion is done, now it’s time to write the answer or the converted value. Move in the direction of the arrows to write the converted value. i.e. 11110

**Step 2: **Completing bits

In this step, we will balance the binary number by completing its bits. A bit is the single unit of a binary number. To complete the bits place a “0” on the left side of the binary number.

0 1 1 1 1 0

**Step 3: **Take the 1’s complement.

To calculate the 1’s complement, change the 0’s into 1’s and vice versa.

1 0 0 0 0 1

**Step 4: **Take the 2’s complement** **

To take the 2’s complement of the inverted value add “1”.

1 0 0 0 0 1

+ 1

1 0 0 0 1 0

**Answer table:**

Decimal value | 30 |

Binary value | 1 1 1 1 0 |

Two’s complement | 1 0 0 0 1 0 |

Taking two’s complement of a number is a bit tricky and time taking task, you can evaluate it by using the __ Two’s complement calculator__ and can save your precious time.

**Example 2:**

Calculate the radix complement of “**1890**”

**Solution:**

**Step 1: **Do the conversion

2 | 1890 |

2 | 945 – 0 |

2 | 472 – 1 |

2 | 236 – 0 |

2 | 118 – 0 |

2 | 59 – 0 |

2 | 29 – 1 |

2 | 14 – 1 |

2 | 7 – 0 |

2 | 3 – 1 |

1 – 1 |

**Binary of 1890 = 1 1 1 0 1 1 0 0 0 1 0**

**Step 2:** Completing bits.

0 1 1 1 0 1 1 0 0 0 1 0

**Step 3:**** **Take the 1’s complement.

To take the 1’s complement swap 0’s by 1’s and 1’s by 0’s.

1 0 0 0 1 0 0 1 1 1 0 1

**Step 4: **Take the radix complement.

1 0 0 0 1 0 0 1 1 1 0 1

+ 1

1 0 0 0 1 0 0 1 1 1 1 0

**Answer table:**

Decimal value | 1890 |

Binary value | 1 1 1 0 1 1 0 0 0 1 0 |

Two’s complement | 1 0 0 0 1 0 0 1 1 1 1 0 |

## In **Conclusion**

In this article, we have studied the basic definition, introduction and some advantages of the two’s complement, this term is usually used to operate the negative decimal numbers and to convert them into binary number system easily.

In the example section, we have discussed the steps for calculating and solving two’s complement of a decimal number. You have witnessed that it is not a difficult topic and now can easily solve all the problems related to this term.

*This will be all for now, ***I understand you may have a question or two to ask, feel free to drop them using the comment box below!**

**Ensure to share this with friends on Facebook, Whatsapp, or any other social media network you can connect them with…**

Related Searches...a. two's complement example b. two's complement calculator c. two's complement in digital systems d. 2's complement subtraction e. 2's complement of binary number