CircuitNote

Quick electronics calculators for lab work and circuit design. Free, no sign-up, works in your browser.

한국어

Values accept SI prefixes. Examples: 4.7k 4k7 100n 10u 20mA 1M

2C

Two's Complement Calculator

See step by step how a negative number becomes two's complement, and find the signed value of any bit pattern.

The binary field uses the number of digits you type as its width, so 1011 is read as 4 bits.

How to form two's complement

For −n, write n in binary, invert every bit and add 1. This lets an adder do subtraction, which is why CPUs and ALUs use it. N bits cover −2N−1 to 2N−1−1.

Worked example: −5 in 8-bit two's complement

  1. Write the magnitude 5 in 8 bits: 0000 0101
  2. Invert every bit: 1111 1010
  3. Add 1: 1111 1011 = 0xFB
  4. Check: 1111 1011 + 0000 0101 = 1 0000 0000 → drop the carry and you get 0

4-bit two's complement table

Bit patternUnsignedTwo's complement
000000
00011+1
00102+2
00113+3
01004+4
01015+5
01106+6
01117+7
10008-8
10019-7
101010-6
101111-5
110012-4
110113-3
111014-2
111115-1

Range by number of bits

BitsSigned rangeUnsigned range
4-8 ~ 70 ~ 15
8-128 ~ 1270 ~ 255
16-32,768 ~ 32,7670 ~ 65,535
32-2,147,483,648 ~ 2,147,483,6470 ~ 4,294,967,295

Frequently asked questions

What is −1 in 8-bit two's complement?

1111 1111 (0xFF). Write 1 as 0000 0001, invert it to 1111 1110 and add 1.

How can I tell if a two's complement number is negative?

Look at the leftmost bit. If it is 1, the number is negative, and its value is the unsigned value minus 2 to the power of the bit width.