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 entered5, 8 bits5,\ 8 \text{ bits}

00000101\displaystyle \mathtt{00000101}

Grouped in fours

0000 0101\displaystyle \mathtt{0000\ 0101}

Hexadecimal

05\displaystyle \mathtt{05}

Read as an unsigned number

5\displaystyle 5
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. Binary form of a non-negative number

    A number that is 00 or more is written in ordinary binary and padded with zeros on the left to 88 bits.

    5=0000010125 = \mathtt{00000101}_{2}
  3. Result

    So 55 is 00000101\mathtt{00000101} in 88 bits.

Worked examples