Fixed-Width Limits and Increment Outcomes

Fixed-Width Limits and Increment Outcomes

Try Press Step from the two 8-bit range tracks to test what happens when the unsigned field at 255 is incremented.

Fixed-Width Limits and Increment Outcomes

Replay

Unsigned 8-bit

0 through 2N − 1 · N = 8

0 (zero)255

Two’s-complement signed 8-bit

−2N−1 through 2N−1 − 1 · N = 8

−1280127

Schematic tracks · spacing carries no numeric scale.

Locate the limits

Width gives both fields the same pattern budget. Signedness changes where the range starts and ends.

Observe The unsigned result card shows 255 plus 1 wrapping to 0, while the clamp card holds at 255. The signed example shows 127 plus 1 reaching −128 under an explicit wrap policy.
Explain An unsigned 8-bit field wraps modulo 2 to the eighth power, so the increment above 255 lands at 0, while a clamp policy holds the value at the upper limit.

Technical boundaries. The track spacing has no numeric scale. The signed wrap result assumes an explicit field policy. In C, narrow operands can be promoted, signed expression overflow is undefined, and C11 and C17 leave out-of-range conversion to a signed integer type implementation-defined.

Back to the chapter