Two's Complement Calculator

Choose encode or decode and enter a number or a bit string.

A whole number that fits in the bits chosen.

Bits

The width of the word.

Try

Result

You entered−128, 8 bits-128,\ 8 \text{ bits}

10000000\displaystyle \mathtt{10000000}

Grouped in fours

1000 0000\displaystyle \mathtt{1000\ 0000}

Hexadecimal

80\displaystyle \mathtt{80}

Read as an unsigned number

128\displaystyle 128
Show the work
  1. Two's complement

    With 88 bits the leftmost bit is the sign (it is 11 for a negative number), and the range is −128-128 to 127127. A negative number −m-m is stored as 28−m2^{8} - m.

  2. The most negative number

    The size 128128 does not fit as a positive number in 88 bits, so use 28−1282^{8} - 128 directly.

    28−128=128=100000002\begin{aligned} 2^{8} - 128 &= 128 \\ &= \mathtt{10000000}_{2} \end{aligned}
  3. Result

    So −128-128 is 10000000\mathtt{10000000} in 88 bits.

Worked examples