Positive integers, including zero, can be represented as unsigned numbers. However, digital systems, such as the computer, must be able to handle both positive and negative numbers. To represent negative integers, we need a notation for negative values. In ordinary arithmetic, a negative number is indicated by a minus sign and a positive number by a plus sign. Because of hardware limitations, computers must represent everything with binary digits. It is customary to represent the sign with a bit placed in the leftmost position of the number. The convention is to make the sign bit 0 for positive and 1 for negative. The remaining bits other than the sign bit represent the magnitude or value of the number.
3 different forms of signed number representation
- Sign-magnitude
- 1’s Complement
- 2’s Complement
2’s complement is the most commonly used signed number representation.
Sign-Magnitude Form
The leftmost bit in a signed binary number is the sign bit, and the remaining bits are magnitude bits. The magnitude bits are in true (uncomplemented) binary for both positive and negative numbers.
Example: Sign-magnitude representation
In the following example, we represent +25 and -25 in sign-magnitude form. Both the numbers are represented in 8-bit signed binary numbers.
+25: 00011001
+25: 10011001
1’s Complement Form
Positive numbers in 1’s complement form are represented the same way as the positive sign-magnitude number. Negative numbers, however, are the 1’s complement of the corresponding positive numbers that can be found by changing all 1s to 0s and all 0s to 1s.
Example: Bit flip for 1’s complement
Example: 1’s complement representation
+25: 00011001
+25: 11100110
2’s Complement Form
Positive numbers in 2’s complement form are represented the same way as the sign-magnitude and 1’s complement forms. Negative numbers are the 2’s complement of the corresponding positive numbers that can be found by adding 1 to the LSB of the 1’s complement of the binary number.
Example: 2’s complement representation
+25: 00011001
+25: 11100111
For a detailed explanation, watch the following lecture video. You can find more examples and a quick trick to find the 2’s complement form in the lecture video.