Two's Complement Converter (8/16/32-bit Binary & Hex)

Convert a signed integer to its two's complement binary and hex at 8, 16 or 32 bits, and decode binary back to signed decimal — runs 100% in your browser, no upload.

🔒 Converted in your browser — nothing is uploaded.

What two's complement is

Two's complement is the standard way computers store signed integers. A positive number looks like its plain binary value, while a negative number is stored by inverting the bits of its magnitude and adding one. This gives a single, unambiguous representation of zero and lets the CPU add and subtract signed numbers with the same circuitry it uses for unsigned ones. The most significant bit acts as the sign: 0 for non-negative, 1 for negative.

Using this converter

Pick a bit width of 8, 16 or 32 bits, then type a signed decimal to see its two's complement binary and hexadecimal, or type a binary pattern to decode it back to a signed decimal. Each field updates the others instantly. The tool enforces the valid range for the chosen width — for example an 8-bit value must be between -128 and 127 — and shows a clear message when a value falls outside it. The hex output is the unsigned bit pattern, which is why -1 shows as 0xFF at 8 bits and 0xFFFFFFFF at 32 bits.

Frequently asked questions

How do I get the two's complement of a negative number?

Take the binary of the absolute value, invert every bit, then add one. This tool does it for you: type the negative decimal and it shows the finished two's complement binary and hex for the bit width you selected.

Why does -1 show as 11111111 or 0xFF?

At 8 bits, -1 is stored as all ones because inverting 00000001 gives 11111110 and adding one gives 11111111. As an unsigned pattern that is 0xFF. Wider widths simply add more leading ones, so -1 is 0xFFFF at 16 bits and 0xFFFFFFFF at 32 bits.

Can I paste a hex value and decode it?

Yes. All three fields are editable, so you can type a hex pattern (with or without a leading 0x) and it is decoded as two's complement to the signed decimal and binary. At 8 bits, 0xFF becomes -1 and 0x80 becomes -128. The hex must have exactly the right number of digits for the width (2, 4 or 8 for 8-, 16- or 32-bit).

Is any of my input uploaded to a server?

No. All conversion happens locally in your browser with JavaScript. Nothing you type is sent, stored or uploaded anywhere.