2.7 Signed Numbers: Sign-Magnitude, 1's Complement, and 2's Complement Ranges
Compute the representable range of an n-bit two's-complement number and explain why negative and positive ranges are asymmetric.
All the number systems covered so far represent only non-negative (unsigned) values. Real computation constantly needs negative numbers as well, and digital hardware must represent a sign using nothing but extra bit patterns, since there is no separate 'minus sign' symbol available at the bit level. Signed number representations are the schemes for encoding both a number's magnitude and its sign within a fixed-width binary word, and three schemes — sign-magnitude, 1's complement, and 2's complement — are in standard use, each with different trade-offs that this topic surveys before the next two topics examine 1's and 2's complement individually in depth.
Three ways to represent a sign
Unsigned representation uses every bit purely for magnitude, so an n-bit unsigned number ranges from 0 to 2^n - 1, with no concept of negative values at all — this is the representation used implicitly in every example up to this point in the module.
Sign-magnitude representation reserves the MSB purely as a sign flag (0 for positive, 1 for negative) and uses the remaining n-1 bits for the magnitude, exactly like writing a plus or minus sign in front of an ordinary decimal number. It is intuitive to read but complicates arithmetic circuit design, because addition and subtraction must handle the sign bit as a special case rather than uniformly with the rest of the number.
1's complement and 2's complement, covered as their own topics next, instead represent a negative number by transforming its positive bit pattern, which — especially for 2's complement — allows the same addition circuitry to correctly handle both positive and negative numbers without special-casing the sign.
The two's-complement range formula
Two's complement (the representation used almost universally in modern processors) allocates its 2^n total bit patterns asymmetrically between positive and negative values: for an n-bit two's-complement number, the representable range is from -2^(n-1) to 2^(n-1) - 1. Notice the range is not symmetric around zero — there is exactly one more negative value representable than positive values.
This asymmetry is not an arbitrary design flaw; it falls directly out of how the MSB works in two's complement. The bit pattern with the MSB set to 1 and every other bit set to 0 (e.g., 1000 0000 in 8 bits) is reserved to represent the single most negative value, -2^(n-1), while there is no equivalent bit pattern left over to represent +2^(n-1) — the largest positive value that fits is one less, 2^(n-1) - 1.
n-bit two's-complement range formula
The total count of representable values, 2^n, is identical between unsigned and two's-complement interpretations of the same n-bit word — signedness changes what the patterns mean, not how many there are.
Range = -2^(n-1) to 2^(n-1) - 1
For n = 8 bits:
Range = -128 to +127
Total distinct values representable = 2^n (unchanged from unsigned;
only how those 2^n patterns are interpreted differs)Code Examples
Substituting n=8 into the range formula gives -128 as the smallest representable value and +127 as the largest. This exactly matches the number of bit patterns available (2^8 = 256): 128 negative values (-128 through -1), one zero, and 127 positive values (1 through 127) — 128 + 1 + 127 = 256.
8-bit two's complement: -128 to +127 (256 total values, but asymmetric ranges)
n = 8
Most negative value: -2^(8-1) = -2^7 = -128
Most positive value: 2^(8-1) - 1 = 2^7 - 1 = 127
Range: -128 to +127 (256 total distinct values, matching 2^8)Sign representation schemes compared (4-bit example)
The same negative value -5 is encoded completely differently depending on which signed representation scheme is used.
Scheme MSB meaning Example: representing -5 (4-bit)
Unsigned no sign, pure magnitude (cannot represent -5)
Sign-magnitude 0=+, 1=- (rest=magnitude) 1101 (sign=1, magnitude=101=5)
1's complement invert bits of +5 (0101) 1010
2's complement 1's complement + 1 1011Important Rules
Unsigned n-bit: range 0 to 2^n - 1, no negative values.
Sign-magnitude: MSB is a pure sign flag (0=positive, 1=negative); remaining n-1 bits hold the magnitude.
Two's-complement n-bit range: -2^(n-1) to 2^(n-1) - 1 — asymmetric, with one extra negative value.
All 2^n bit patterns are used in every scheme; signedness changes interpretation, not the count of distinct patterns.
Where this shows up
Every signed integer type in a programming language (e.g., a signed 32-bit int, which ranges from -2,147,483,648 to +2,147,483,647) is implemented using two's complement in essentially every modern processor, which is why that particular asymmetric range — one more negative value than positive — appears as a well-known 'gotcha' constant across virtually every programming language's standard library.
Assuming an n-bit signed range is symmetric, e.g., guessing 8-bit two's complement spans -127 to +127.
Apply the actual formula: -2^(n-1) to 2^(n-1)-1, giving -128 to +127 for 8 bits — one more negative value than positive.
Two's complement reserves the bit pattern with MSB=1 and all remaining bits zero for the single value -2^(n-1), with no corresponding positive counterpart bit pattern available, which is exactly why there is one more negative value than positive value in two's-complement representation.
[tricky] Why is there one more negative value than positive value in an n-bit two's-complement system? A. Because two's complement always rounds down when converting negative numbers B. Because two's complement reserves the bit pattern with MSB=1 and remaining bits zero for -2^(n-1), and no corresponding bit pattern is left available for +2^(n-1) C. Because negative numbers require one extra bit to store the sign D. It is a hardware limitation that only applies to 8-bit systems
B. Because two's complement reserves the bit pattern with MSB=1 and remaining bits zero for -2^(n-1), and no corresponding bit pattern is left available for +2^(n-1) — Two's complement reserves the bit pattern with MSB '1' and remaining bits zero for -2^(n-1). Since all 2^n bit patterns must be assigned exactly once, and one of them uniquely represents the extreme negative value, the range of positive values is exactly one value shorter, topping out at 2^(n-1)-1.
[interview] What is the key practical disadvantage of sign-magnitude representation compared to two's complement? A. Sign-magnitude cannot represent negative numbers at all B. Sign-magnitude requires special-case handling in addition/subtraction circuits because the sign bit must be treated separately from the magnitude bits, unlike two's complement where ordinary addition works uniformly for positive and negative operands C. Sign-magnitude uses more bits than two's complement for the same range D. Sign-magnitude is only usable for floating-point numbers
B. Sign-magnitude requires special-case handling in addition/subtraction circuits because the sign bit must be treated separately from the magnitude bits, unlike two's complement where ordinary addition works uniformly for positive and negative operands — In sign-magnitude, the sign bit is separate from the magnitude, so an adder circuit cannot simply add two sign-magnitude numbers bit-by-bit and get a correct signed result — it must detect signs and conditionally add or subtract magnitudes. Two's complement avoids this entirely, which is why it is the near-universal choice in real processors.
State the representable range of a 16-bit two's-complement signed number, and explain in one sentence why the most negative value has no positive counterpart.
Range = -2^15 to 2^15-1 = -32768 to +32767. The most negative value has no positive counterpart because two's complement reserves the single bit pattern with MSB=1 and all other bits 0 exclusively for -2^(n-1), leaving no equivalent unused pattern to represent +2^(n-1).
Substitute n=16 into the range formula, and think about which single bit pattern gets 'used up' representing the most negative value.