Two's complement calculator

Enter a number — decimal, hexadecimal or binary — choose the bit width, and see its two's complement representation, how it reads as a signed and as an unsigned value, and the invert-and-add-one steps for negatives.

Step by step

Type a number to see how its two’s complement is built.

What two's complement is

Two's complement is how virtually every CPU stores signed integers. The highest bit acts as a sign: when it's set, the value is negative. To negate a number you invert every bit and add one. The trick is that addition and subtraction then work identically for positive and negative values — the hardware doesn't need special cases.

-42 in 8 bits: 42 = 00101010 → invert → 11010101 → +1 → 11010110

The same bit pattern means different things depending on interpretation: 11010110 is −42 as a signed byte but 214 as an unsigned one. That's exactly why this calculator shows both readings — and why the HexCalculator app has a Signed/Unsigned switch.

Ranges per bit width

BitsSigned rangeUnsigned range
8−128 … 1270 … 255
16−32 768 … 32 7670 … 65 535
32−2 147 483 648 … 2 147 483 6470 … 4 294 967 295
64−2⁶³ … 2⁶³−10 … 2⁶⁴−1

Related tools and guides