← All Tools

Two's Complement: How Computers Represent Negative Numbers

Guide · Last verified Aug 26, 2026

Type any number into the Number Base Converter and look at its signed 32-bit integer value, and eventually you'll hit a moment where the binary representation defies intuition. For example, 0xFFFFFFFF, where all 32 bits are 1, looks like "the largest possible binary number" — but it's actually -1. That's not a bug; it's a direct result of how computers store negative numbers, a scheme called two's complement.

1. Why a Single Sign Bit Isn't Enough

The simplest way to represent a negative number is "sign and magnitude": use the most significant bit for the sign and the rest of the bits for the absolute value. It's intuitive, but it has two problems. One is that zero ends up with two representations (+0 and -0). The other is that addition and subtraction circuits have to branch based on the sign, which makes the hardware more complex. Two's complement was devised to solve both problems at once, and today nearly every CPU uses it for integer arithmetic.

2. How to Construct Two's Complement

To find the negative representation of a positive number n, you flip every bit (giving the one's complement) and then add 1. Working through an 8-bit example: 1 is 00000001. Flip it to get 11111110, then add 1 to get 11111111 — that's the 8-bit representation of -1. In 32 bits, you apply the exact same process across 32 digits, so the value with every bit set to 1 (0xFFFFFFFF) becomes -1. Conversely, 0x80000000 — where only the most significant bit is 1 and every other bit is 0 — is the minimum value of a 32-bit signed integer, -2,147,483,648.

Core rule: In a 32-bit integer, if the most significant bit (MSB) is 1, the number is negative; if it's 0, the number is positive. A negative number's actual value equals "2^32 minus the bit pattern read as an unsigned number." Example: 0xFFFFFFFF → 2^32 − 4,294,967,295 = 1, so the value is -1.

3. Why There's Only One Zero

In sign-magnitude representation, +0 (00000000) and -0 (10000000) exist as two separate patterns representing the same value — a wasted bit pattern. In two's complement, if you flip 0 and add 1, you get 00000000 → 11111111 → (a carry occurs) → 00000000 — it lands back on itself. So in two's complement, exactly one bit pattern corresponds to zero, which frees up one extra value on the representable range (for example, in 8 bits the range is -128 to 127 — one more negative value than positive value).

4. Why Addition Circuits Get Simpler

The real advantage of two's complement is that you can ignore sign entirely and just perform plain binary addition, and subtraction gets handled automatically along the way. For example, 5 − 3 can be rewritten as 5 + (-3) and simply added. In 8 bits: 00000101 (5) + 11111101 (-3) = 100000010 — since the carry beyond the 8th bit is discarded, what's left is 00000010, or 2. For a CPU, this means a single adder circuit can handle both addition and subtraction of signed integers, which greatly simplifies the hardware. Plug several values into the Number Base Converter yourself and watch the Signed 32-bit results — it's a good way to see this principle firsthand.

5. How the Number Base Converter Actually Handles This

Looking at this calculator's code, it converts the input using the n >>> 0 operation to get a 32-bit unsigned integer for the Unsigned display, and uses the n | 0 operation to get a 32-bit signed integer for the Signed 32-bit display. Both operations follow the two's complement rule precisely inside the JavaScript engine, so — as mentioned above — entering 0xFFFFFFFF produces exactly 4,294,967,295 for Unsigned and -1 for Signed. A 32-bit binary grid is also displayed alongside the result, so you can see at a glance whether the most significant bit is 1.

HexUnsignedSigned 32-bit (two's complement)
0x0000000111
0x7FFFFFFF2,147,483,6472,147,483,647 (maximum)
0x800000002,147,483,648-2,147,483,648 (minimum)
0xFFFFFFFF4,294,967,295-1

Frequently Asked Questions

Q. Why does a 1 in the most significant bit always mean negative?

In two's complement, the most significant bit effectively carries a weight of "-2^(number of bits - 1)." For 32 bits, when the MSB is 1, it adds a large negative value of -2^31 (about -2.1 billion), which forces the overall value to be negative no matter what the remaining bits are.

Q. Why does overflow happen?

Add 1 to 2,147,483,647 (0x7FFFFFFF, the maximum 32-bit signed integer) and the bit pattern becomes 0x80000000, which flips over to the minimum value, -2,147,483,648. This phenomenon is called integer overflow, and it's a natural consequence of the two's complement structure.

Q. Does the same principle apply on 64-bit systems?

Yes — only the bit count changes from 32 to 64. The rule of flip-then-add-1, and the most significant bit determining the sign, stays exactly the same. That said, this Number Base Converter operates on a 32-bit basis, so handling 64-bit values accurately requires a separate tool that supports BigInt.

Q. Are negative floating-point numbers also two's complement?

No. Floating-point numbers follow the IEEE 754 standard, using just a single sign bit (similar to sign-magnitude), with separate exponent and mantissa fields. Two's complement is a representation used only for integer arithmetic.