I elaborate with the following examples. The 4-bit binary representation of decimal 5 is 0101. So decimal -5 is represented in 2's complement as 1011. However, 1011 is also the binary representation of decimal 11. How does one differentiate these two?
If the solution is to restrict 4-bit binary numbers to represent -8 to +7 only, how is an overflow detected? When I add binary 7 to binary 7, I get 1110 which is decimal 13 (overflow), but also binary -2 in 2's complement. How does one detect that binary 7+7 is an overflow, and not -2?
I understand that computers generally use 2's complement to represent negative numbers. I want to know how this problem is dealt with in that context.