Sign-magnitude is the most obvious way to store negative numbers: copy what we do on paper. The MSB is the sign (0 for +, 1 for −), and the remaining bits are the magnitude, read as ordinary unsigned binary.
In 4 bits, 0101 = +5 and 1101 = −5.
It's easy for people to read, but it has two real problems:
- Two zeros.
0000is +0 and1000is −0. One pattern is wasted, and comparison logic has to treat both as equal. - Ordinary adders get it wrong. +1 + (−1) =
0001+1001=1010, which reads as −2. Hardware would have to compare the signs and subtract magnitudes instead.
With n bits it covers −(2ⁿ⁻¹ − 1) to +(2ⁿ⁻¹ − 1). In 8 bits that's −127 to +127, one value fewer than twos complement because of the second zero.
That's why integers use two's complement. Sign-magnitude still lives on in floating-point numbers, where a separate sign bit sits in front of the exponent and fraction.