Computers: Numbers: Representing Signed Integers

Positive binary integers have a very natural representation. Several systems have been used to represent negative integers. Some of the most common are listed below. The even number of bit patterns in a given amount of memory (eg, the 32 bits that are typically allocated for an integer) has some interesting consequences for representing signed numbers.

Negative integers

Sample values

Here are some sample values of 8-bit integer representations.

Signed
Magnitude
One's
Complement
Two's
Complement
Excess
bias 127
Unsigned
-128 none none1000 0000nonenone
-1271111 11111000 00001000 00010000 0000none
-21000 00101111 11011111 11100111 1101none
-11000 00011111 11101111 11110111 1110none
00000 0000
1000 0000
0000 0000
1111 1111
0000 00000111 11110000 0000
+10000 00010000 00010000 00011000 00000000 0001
+20000 00100000 00100000 00101000 00010000 0010
+1260111 11100111 11100111 11101111 11010111 1110
+1270111 11110111 11110111 11111111 11100111 1111
+128nonenonenone1111 11111000 0000
+129nonenonenonenone1000 0001
+255nonenonenonenone1111 1111

And the winner is: Two's complement

The most compelling factors for microprocessor manufacturers are speed (maximize), integrated circuit "real estate" (minimize), and power requirements (minimize). Two's complement must have advantages over other systems because all new CPUs use it.