Create Date: July 8, 2024
Last Modified Date: December 17, 2024
Two's complement is used because it simplifies the design of arithmetic circuits. It allows both addition and subtraction to be performed using the same hardware and eliminates the need for checking the sign of operands during calculation.
Two's complement can represent a symmetrical range of positive and negative integers. For a given number of bits n, it can represent integers from -2^(n-1) to 2^(n-1)-1. For example, with 8 bits, it can represent numbers from -128 to 127.
If the result of an operation in two's complement exceeds the number of bits available, it leads to an overflow. The overflow causes the most significant bit (sign bit) to flip, which can lead to incorrect results if not properly managed.