Signed Number Representation: Two's Complement

Understanding range and sign extension for N-bit signed integers

Range Formula
-2N-1 to +2N-1 - 1
3-bit
-4 to +3
4-bit
-8 to +7
5-bit
-16 to +15
MSB is the Sign Bit
Most significant bit indicates sign: 0 = positive, 1 = negative
Asymmetric Range
One more negative than positive (e.g., -128 to +127 for 8-bit)
Sign Extension Preserves Value
Copying sign bit when widening maintains the same value

Two's Complement Representations

Decimal 3-bit 4-bit 5-bit
Sign Extension Demonstration
Extending -3: Copy sign bit (1) to new positions
101
1101
11101
= -3
Extending +3: Copy sign bit (0) to new positions
011
0011
00011
= +3
Key Insight: Copy the Sign Bit
Sign extension preserves value by replicating the MSB into new high-order positions