The most negative 8-bit value — two's complement

corethe asymmetric range

Answer

10000000

Why this example is worth doing

Eight-bit two's complement spans −128 to +127, which is asymmetric: there is a most negative value with no positive counterpart. The consequence is a real bug class — negating −128 gives −128 back, because the answer does not fit — and the page demonstrates that overflow explicitly. This asymmetry is the price of having exactly one representation of zero, which the page contrasts with sign-magnitude.

Try your own input in the Two’s complement. Encode and decode signed binary at any width, with overflow and sign extension.

How the answer is reached

-128 in 8-bit two's complement

Encode -128 in 8-bit two's complement. Representable range: -128 to 127.

|-128| in binary10000000

invert every bit01111111

add 110000000invert-and-add-one is the negation rule

8-bit pattern1000 00000x80

check10000000 reads 128 unsigned and -128 signed

Compare with

Open this example in the Two’s complement

The field arrives filled in with this example’s input.

Note:

Notation this page assumes

  • Bit strings are written most significant bit first, and bit 0 is the least significant bit.
  • A width is stated explicitly wherever it changes the answer; nothing is silently sign-extended or truncated.
  • Negative values are two’s complement, not sign–magnitude, and the most significant bit is the sign bit.

Sources

  • Knuth, The Art of Computer Programming, Vol. 2, §4.1 “Positional Number Systems” (1997)
  • IEEE 754-2019, Standard for Floating-Point Arithmetic