Calcy Mate Logo
Math Calculators

Two's Complement Calculator

Convert signed integers to two's complement binary and read signed binary back to decimal for any common bit width (4–64 bits or custom).

CalcyMate
CreatorCalcyMate

If you've ever wondered how computers store negative numbers in binary, the answer is two's complement. It's the universal method modern processors use to represent signed integers — and once you understand it, binary arithmetic suddenly makes a lot more sense.

Our two's complement calculator at CalcyMate lets you convert any decimal number to its two's complement binary form, or go the other way and read a binary number as a signed decimal. Just pick your bit width, enter a value, and get the result instantly. This guide walks you through the concept, both formulas, and real examples so you fully understand what's happening under the hood.

Two's Complement Calculator — Signed Binary Conversion Made Simple

The two's complement calculator works both ways. Enter a decimal number and get its two's complement binary. Enter a binary string and read it back as a signed decimal. The default is 8-bit, and the binary output appears in groups of four bits so it's easy to read. Whether you're a CS student, a developer, or just someone curious about how CPUs work, this tool gives you clean, instant conversions.

What Is Two's Complement?

Two's complement is the standard way computers represent signed integers — especially negative numbers — in binary. The Most Significant Bit (MSB), which is the leftmost bit, acts as the sign bit: 0 means positive, 1 means negative.

To convert a positive number into its negative two's complement form, you flip all the bits (turn every 0 into a 1 and every 1 into a 0), then add 1. That's it. This is also written as: one's complement + 1.

Two reasons this system dominates computing:

  • Subtraction becomes addition. The CPU doesn't need separate subtraction hardware — it just adds a negative number.

  • There's only one zero. One's complement has a positive zero and a negative zero, which breaks arithmetic. Two's complement fixes that completely.

The Two's Complement Formulas

Formula 1: Decimal to Two's Complement Binary

To convert a negative decimal −A into an N-bit two's complement binary:

Two's Complement = 2^N − A

You can also find the binary for positive A, flip all bits, and add 1. Both methods give the same result.

Formula 2: Two's Complement Binary to Decimal

To read an N-bit two's complement binary as a signed decimal, use the weighted positional formula. The MSB carries a negative weight:

Decimal = −b(N−1) × 2^(N−1) + b(N−2) × 2^(N−2) + ... + b1 × 2^1 + b0 × 2^0

Every bit adds its positional value — except the MSB, which subtracts.

How the Two's Complement Calculator Works

Inputs

  • Binary number representation (bits) — Dropdown to select bit width. Default is 8-bit, covering signed integers from −128 to 127.

  • Decimal → binary (two's complement) — Type any whole number between −128 and 127. The calculator converts it to two's complement binary instantly.

  • Binary → decimal (signed) — Type a binary string up to 8 digits. Spaces are ignored. The calculator returns the signed decimal value.

Outputs

  • Binary result displays in groups of four bits (e.g., 0001 0000).

  • Decimal result shows the signed integer for your binary input.

  • Quick check examples appear below the fields for instant reference.

How to Use the Two's Complement Calculator — Step by Step

Example 1: Decimal to Binary

The default input is decimal 16 with 8-bit selected.

16 is positive, so no flipping needed. Convert directly to binary:

16 = 0001 0000

The calculator output: 0001 0000

16 sits well within the 8-bit signed range of −128 to 127.

Example 2: Binary to Signed Decimal

The quick check shows signed binary 10111011 → should give −69.

Bits from b7 to b0: 1, 0, 1, 1, 1, 0, 1, 1

Decimal = −(1×128) + (0×64) + (1×32) + (1×16) + (1×8) + (0×4) + (1×2) + (1×1)

= −128 + 0 + 32 + 16 + 8 + 0 + 2 + 1

= −128 + 59 = −69

Type 10111011 into the binary → decimal field on CalcyMate and you get −69 right away.

Two's Complement Reference Table

Decimal

8-bit Two's Complement Binary

127

0111 1111

16

0001 0000

1

0000 0001

0

0000 0000

−1

1111 1111

−16

1111 0000

−69

1011 1011

−128

1000 0000

Note: All values are 8-bit. A 1 in the MSB (leftmost bit) always means negative. A 0 always means positive.

Where Two's Complement Shows Up in Real Life

CPU arithmetic — Every modern processor does addition, subtraction, and multiplication using two's complement. The same circuit handles both positive and negative numbers — no separate subtraction unit needed.

Programming data types — When you declare a signed integer in C, Java, or Python, the compiler stores it in two's complement in memory. That's why an 8-bit signed integer goes from −128 to 127, not 0 to 255.

Digital signal processing — Audio and video processors use two's complement to handle signed sample values in real time, making filtering, compression, and mixing work efficiently at the hardware level.

Fun Fact

Two's complement wasn't invented by a computer scientist. Gottfried Wilhelm Leibniz — the same person who co-invented calculus — described the underlying math in the 17th century while studying number systems for completely unrelated reasons. Early computers in the 1940s used sign-and-magnitude representation instead, which produced two different zeros and drove engineers absolutely mad. Two's complement eventually took over, and everyone finally relaxed. 😄

Frequently Asked Questions

Why is it called two's complement?

The name comes directly from the math. For an N-bit number, two's complement of A equals 2^N − A. The "2" refers to base-2 (binary), and "complement" means the value that rounds the number up to a power of 2. So the name literally describes the operation.

Can two's complement represent positive numbers too?

Yes. Any number with a 0 in the MSB is positive and stored in standard binary. Two's complement only changes how negative numbers look. Positive numbers stay exactly the same as regular unsigned binary.

What happens if a number is outside the bit range?

You get an overflow. For 8-bit two's complement, the valid range is −128 to 127. If you go beyond that, the result wraps around incorrectly. For example, 127 + 1 in 8-bit two's complement gives −128, not 128. This is a classic overflow bug in low-level programming.

Choose a bit width, then convert a signed integer to two’s complement binary or type binary to read it as signed decimal. Leading zeros in binary are optional; values are padded to the selected width.

Signed range for 8 bits: -128 … 127

Decimal → binary (two's complement)

Whole numbers from -128 through 127.

Binary → decimal (signed)

Up to 8 digits (0/1); spaces are ignored for counting. Result is shown in groups of four bits.

Quick checks

  • : decimal 16 (8-bit)
  • : signed binary 10111011 (needs ≥ 8 bits → −69)