← Back to tool

Signed binary · 8/16/32/64-bit

Two's Complement Converter

Updated: June 2026

Computers store negative integers using two's complement, a clever scheme that lets the same addition circuit handle positive and negative numbers without a separate sign rule. Understanding it is the key to reading any signed binary or hex value correctly.

Open the Converter →

Pick a bit width, type a negative number · Free · No upload

The invert-and-add-one rule

To represent a negative number in a fixed bit width: write the absolute value in binary, pad it to the full width, flip every bit (the one's complement), then add one. Here is −5 in 8 bits:

5      = 0000 0101
invert = 1111 1010
add 1  = 1111 1011   → -5 (0xFB)

The leftmost bit is now 1, marking the value as negative. Adding 5 and −5 in this form gives 1 0000 0000 — the carry out of the top falls off the fixed width, leaving 0, exactly as arithmetic should.

Reading a two's complement value back

If the most significant bit is 0, the number is positive — read it normally. If it is 1, the number is negative: invert all the bits and add one to get the magnitude, then attach a minus sign. For 1111 1011: invert to 0000 0100, add one to get 0000 0101 = 5, so the value is −5. The converter does this automatically when you choose a bit width.

Ranges by width

WidthSigned range−1 in hex
8-bit−128 … 127FF
16-bit−32,768 … 32,767FFFF
32-bit−2,147,483,648 … 2,147,483,647FFFFFFFF
64-bit±9.22 × 10¹⁸FFFFFFFFFFFFFFFF

The range is asymmetric: there is one more negative value than positive because zero takes a slot on the positive side. That extra value is the most negative number (e.g. −128 in 8-bit), whose negation overflows back to itself — a classic source of bugs.

Why two's complement won

  • One representation of zero (unlike sign-magnitude, which has +0 and −0).
  • Addition and subtraction use the same hardware with no special-casing for signs.
  • Overflow detection is a simple carry/sign-bit check.
  • Sign extension to a wider type just copies the top bit.

Using the tool

Select a bit width (8, 16, 32 or 64), then type a negative decimal. The binary and hex rows immediately show the two's complement pattern, and the bit view lets you click individual bits to see how the value changes. Switch the width on the fly to compare how the same number looks at different sizes — handy when porting code between int8_t, int16_t and int32_t.

Frequently asked questions

How do you find the two's complement?

Write the magnitude in binary at the chosen width, invert every bit, then add one.

What is -1 in two's complement?

All ones at every width — 11111111 in 8-bit, which is FF in hex.

What is the 8-bit signed range?

−128 to +127. The high bit is the sign, and there is one extra negative value.

Why add one after inverting?

Inverting alone gives one's complement, which has two zeros. Adding one shifts the scheme so there is a single zero and clean arithmetic.