Two's Complement Calculator

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

Zeros and ones, from 2 to 64 of them. The first bit is the sign.

Try

Result

You entered111110112\mathtt{11111011}_{2}

−5\displaystyle -5

Read as an unsigned number

251\displaystyle 251

Hexadecimal

FB\displaystyle FB

Number of bits

8\displaystyle 8
Show the work
  1. Place values in two's complement

    In 88 bits the leftmost bit has the place value −27=−128-2^{7} = -128, which is negative; every other bit has the usual positive power of 22.

  2. Adding the place values of the 1 bits

    Add the place value of every bit that is 11 and ignore the zeros.

    −128+64+32+16+8+2+1=−5-128 + 64 + 32 + 16 + 8 + 2 + 1 = -5
  3. Result

    So 11111011\mathtt{11111011} stands for −5-5.

Worked examples