Digital Logic

Sign Extension

The process of increasing the bit width of a signed number while preserving its value by replicating the sign bit.

Detailed Explanation

Two's complement numbers use the MSB as a sign bit. To extend from N bits to M bits (M > N), replicate the sign bit into the new high-order positions. This preserves the numeric value: -5 as 4-bit 1011 becomes 8-bit 11111011.

Sign extension is necessary when operations require operands of different widths, such as adding a byte to a word. Zero extension is used for unsigned numbers.