Skip to content
BinaryTo

Two's Complement Calculator

This two's complement calculator turns a negative number into binary, or reads a two's complement number back as decimal. Pick 4, 8, 16 or 32 bits and it shows each step: write the number, invert every bit, add 1.

Two's complement

Direction
Width

Two's complement

How to find the two's complement

  1. 01

    Write the number in binary

    Leave out the minus sign and pad to the full width: 5 in 8 bits is 00000101.

  2. 02

    Invert every bit

    Every 0 becomes 1 and every 1 becomes 0: 11111010.

  3. 03

    Add 1

    11111010 + 1 is 11111011, which is −5 in 8-bit two's complement.

Reading two's complement

If the leftmost bit is 0, the number is positive: read it as plain binary. If it is 1, the number is negative: invert every bit, add 1, and put a minus sign in front. 11111011 inverts to 00000100, plus 1 is 00000101, so it is −5.

Another way: the leftmost bit is worth minus its usual value. In 8 bits it is worth −128, so 11111011 is −128 + 64 + 32 + 16 + 8 + 2 + 1 = −5.

4-bit two's complement table

All 16 patterns of 4 bits, read as unsigned and as two's complement. Four bits hold −8 to 7.

4-bit two's complement table
BinaryUnsignedTwo's complement
000000
000111
001022
001133
010044
010155
011066
011177
10008-8
10019-7
101010-6
101111-5
110012-4
110113-3
111014-2
111115-1

Range by width

Range by width
BitsSmallestLargest
4−87
8−128127
16−32,76832,767
32−2,147,483,6482,147,483,647

Frequently asked questions

What is two's complement?

Two's complement is how computers store negative whole numbers. The leftmost bit is the sign: 0 for positive, 1 for negative. The same adding circuit then works for positive and negative numbers, which is why nearly every processor uses it.

How do you find the two's complement of a number?

Write the number in binary at the chosen width, invert every bit, then add 1. For −12 in 8 bits: 12 is 00001100, inverted is 11110011, plus 1 is 11110100.

How do you convert two's complement to decimal?

If the first bit is 0, read it as plain binary. If it is 1, invert every bit, add 1, and make the result negative: 1110 inverts to 0001, plus 1 is 0010, so it is −2.