Free Online Engineering Tools

Two's Complement Calculator — Signed Binary Converter

Convert between signed decimal and two's complement binary at 8, 16 or 32 bits. Type a value in either box and watch the invert-and-add-1 steps, the sign bit, hex and the representable range update live.

1Enter Decimal or Binary
📏Bit Width
DECSigned Decimal−128 … 127
BINTwo's Complement Binary8 bits
💡
Pro Tip
Type a signed decimal (negatives allowed) or a binary pattern — the other updates instantly. The sign bit (leftmost) is 0 for positive, 1 for negative.
2Invert & Add 1 — Step by Step
3Results
Signed Decimal
−5
Two's Complement
11111011
Hexadecimal
0xFB
Sign Bit
1 (negative)
Unsigned Value
251
Representable Range
−128 to 127
How to Read It
For a negative number, invert every bit of the positive value and add 1. The leftmost bit is the sign: 1 means negative.

What Is Two's Complement?

Two's complement is the standard way computers represent signed integers — both positive and negative whole numbers — in binary. Positive values look like ordinary binary; a negative value is formed by inverting every bit of its positive form and adding 1. The leftmost bit becomes the sign bit: 0 for positive, 1 for negative. Its great advantage is that a single adder circuit can perform both addition and subtraction, which is why virtually every CPU uses two's complement internally. This calculator converts between signed decimal and two's complement binary at 8, 16 or 32 bits and shows the invert-and-add-1 steps as you type.

How to Use This Calculator

1. Pick a bit width — 8, 16 or 32 bits. 2. Type a signed decimal (negatives allowed) or a binary pattern. The other field updates instantly. 3. Read the step-by-step panel to see how a negative number is built by inverting the positive value and adding 1. 4. Check the results for the sign bit, hexadecimal, the raw unsigned value and the representable range. Out-of-range values are flagged per field.

How to Find the Two's Complement (Invert and Add 1)

Example — encode −5 in 8-bit

+5  = 0000 0101
invert = 1111 1010  (one's complement)
add 1  = 1111 1011  (two's complement)

So −5 is 11111011 (0xFB). The sign bit is 1, confirming a negative number.

How to Convert Two's Complement Back to Decimal

Look at the sign bit (leftmost). If it is 0, read the binary value normally. If it is 1, the number is negative: invert all the bits, add 1, convert to decimal and prefix a minus sign. For example, 11111011 has sign bit 1, so invert to 00000100, add 1 to get 00000101 = 5, giving −5. Alternatively, treat the sign bit as a negative place value: for 8 bits it is worth −128, so 11111011 = −128 + 64 + 32 + 16 + 8 + 2 + 1 = −5.

Two's Complement Range by Bit Width

BitsMinimumMaximumCommon type
8−128127signed char / int8
16−32,76832,767short / int16
32−2,147,483,6482,147,483,647int / int32

In general an n-bit two's complement value spans −2n−1 to +2n−1−1. The negative side reaches one further than the positive because zero occupies one of the non-negative slots.

Two's Complement vs One's Complement vs Sign-Magnitude

SchemeHow −5 looks (8-bit)ZerosUsed today?
Sign-magnitude1000 0101two (+0, −0)rarely
One's complement1111 1010two (+0, −0)rarely
Two's complement1111 1011oneyes, universal

Two's complement wins because it has a single zero and one adder handles both addition and subtraction — subtracting is just adding the complement.

Where Two's Complement Is Used

It is everywhere signed integers appear: C/C++/Java int types, assembly and machine code, CPU arithmetic logic units, network protocols, and file formats. Understanding it explains integer overflow (adding 1 to the maximum wraps to the minimum) and negative-number bit patterns you see in a debugger. Do full signed arithmetic in the Binary Calculator, switch bases in the Number System Converter, or explore per-bit logic in the Bitwise Calculator and Bit Shift Calculator.

Next step: See how signed subtraction becomes addition in the Binary Calculator, or check the logic behind the bits in the Logic Gate Calculator.

Exploring other binary encodings? The Gray Code Converter handles reflected binary code, where consecutive values differ by only one bit.

Frequently Asked Questions

What is two's complement?

The standard binary representation of signed integers. Positives are normal binary; a negative is the positive value with every bit inverted and 1 added. The leftmost bit is the sign (0 positive, 1 negative).

How do you find the two's complement of a binary number?

Invert every bit of the positive value (one's complement), then add 1. +5 = 00000101 → 11111010 → 11111011 = −5.

How do you convert two's complement back to decimal?

If the sign bit is 0, read it as normal binary. If it is 1, invert, add 1, convert and add a minus sign — or weight the sign bit as a negative place value.

What is the range of an 8-bit two's complement number?

−128 to +127. In general n bits span −2n−1 to +2n−1−1.

Why do computers use two's complement instead of sign-magnitude?

It has a single zero and lets one adder do both addition and subtraction, simplifying the CPU's arithmetic unit.

What is the difference between one's and two's complement?

One's complement is just the inverted bits; two's complement is that plus 1. One's complement has two zeros and needs an end-around carry, so two's complement is preferred.