Two's Complement Calculator

Convert signed decimals to two's complement binary/hex and back, with every step.

What it does

Two’s complement is how computers store negative integers. Convert a signed decimal to binary/hex, or decode binary back to decimal, with every step shown.

Where it's used

Embedded programming, reading sensor registers that hold signed values and computer-architecture courses.

How to use it

  1. Choose decimal → binary or binary/hex → decimal.
  2. Type the value.
  3. For decimal → binary, choose the bit width.

The formula explained

−x
(invert all bits of x) + 1
MSB
the top bit is the sign: 1 means negative
Range
−2ᴺ⁻¹ … 2ᴺ⁻¹ − 1 for N bits

Worked example

−100 stored in 16 bits.

Inputs:

The calculator gives:

Tips and common mistakes

Questions people ask

How do I find the two’s complement by hand?

Write the positive number in binary, invert every bit and add 1. For −100 in 8 bits: 100 = 0110 0100 → 1001 1011 → 1001 1100, which is 0x9C.

What range do N bits hold?

From −2^(N−1) to 2^(N−1) − 1. That is −128 to 127 in 8 bits, −32 768 to 32 767 in 16 bits and about ±2.1 billion in 32 bits.

Why do computers use two’s complement?

Addition and subtraction work the same way for signed and unsigned numbers, so one adder serves both, and there is only one zero (unlike sign-and-magnitude, which has +0 and −0).

Related Digital Logic calculators

Enter your values to get the result with the formula, substituted values and an explanation of each step.

All engineering calculators