How two's complement works

A fixed-width integer is stored as a pattern of bits with no separate sign field. Instead, the top bit doubles as a sign in signed mode: 0 for non-negative, 1 for negative. Flipping every bit and adding 1 negates a value. Arithmetic wraps around at the width, so incrementing the all-ones pattern rolls back to all zeros.

The same bits mean different things depending on how they're read. The byte 11111111 is 255 unsigned, but −1 signed. Because the signed range is asymmetric around zero (one more negative value than positive), negating the most negative signed value (like −128 for 8 bits) has no positive counterpart to land on — it overflows and produces itself again.

Try the Min, Max, -1, and 0 buttons, then +1 or Negate, to see where a width's range wraps around.