LOGBOOK

HELP

Quiz Entry - updated: 2026.07.07

What is sign extension and when is it used?

To widen a signed value, copy its sign bit into all the new high bits — that keeps the number's value (and sign) unchanged.

Widening 0101 (+5) and 1011 (−5) from 4 to 8 bits by copying the sign bit

* Widening from 4 to 8 bits: the new high bits are filled with copies of the sign bit, so +5 stays 00000101 and −5 stays 11111011. *

Used when converting a smaller signed type to a larger one.

Example: 4-bit → 8-bit

Positive: 0101 (+5) → 00000101 (+5)
Negative: 1011 (-5) → 11111011 (-5)

Rule: Copy the sign bit (MSB) into all new positions.

Why it works: The negative weight of the sign bit doubles with each added bit, but adding another copy of the sign bit compensates.

In C: Automatic when assigning char to int, short to long, etc.

Go deeper:

From Quiz: REVE1 / Number Representations | Updated: Jul 07, 2026