Developer

Encoders, converters & dev utilities

12 tools
Developer · Number-Base Converter

Two's Complement Converter — Signed Binary Explained

Two's complement is how computers store signed integers, and this tool converts between a signed value and its binary form at any bit-width. The rule: within n bits, a negative value x is stored as 2ⁿ − |x|, and the most significant bit acts as the sign (1 = negative). Worked example: in 8 bits, 11111111₂ is not 255 but −1, because 2⁸ − 255 = 1, so those bits represent −1. Likewise 10000000₂ (8-bit) is the minimum, −128. The identical bit pattern means 255 unsigned or −1 signed — only the interpretation and the chosen bit-width differ. The tool lets you set the width (4/8/16/32/64), uses BigInt so wide values stay exact, and runs 100% in your browser. Free, no login.

Quick answer

Two's complement (width n): a negative x is stored as 2ⁿ − |x|; the most significant bit is the sign (1 = negative)

  • Byte-exact worked example: signed 8-bit 11111111₂ = 2⁸ − 255 = −1 (NOT 255 — that is the unsigned reading)
  • Range edge: 8-bit 10000000₂ = −128 (the minimum), 01111111₂ = +127 (the maximum)
  • Same bits, two meanings: 11111111₂ = 255 unsigned OR −1 signed — the bit-width + signedness decide
  • Set the width (4/8/16/32/64); wide values use BigInt (no float error); runs 100% client-side
Open the full Number-Base Converter

Frequently asked questions

What is two's complement?

Two's complement is the standard way computers represent signed integers in a fixed number of bits. A positive number is its plain binary form; a negative number x is stored as 2ⁿ − |x| within n bits, which makes the most significant bit a sign flag (1 means negative). Its advantage is that ordinary binary addition works for both positive and negative numbers with no special cases, which is why virtually all CPUs use it.

Why is 11111111 equal to −1 in signed 8-bit?

Because in 8-bit two's complement a negative value x is stored as 2⁸ − |x| = 256 − |x|. For −1 that is 256 − 1 = 255, whose binary is 11111111. So the bit pattern 11111111 read as a signed 8-bit number is −1, even though the same bits read as unsigned are 255. The leading 1 tells you it is negative; the bit-width (8) tells you which wrap-around applies.

How can the same bits be both 255 and −1?

The bits alone do not carry a sign — the interpretation does. 11111111 is 255 when treated as an unsigned 8-bit number, and −1 when treated as a signed 8-bit two's-complement number. Nothing about the storage changes; only the convention your program uses to read it. That is why declaring the correct width and signedness matters, and why this tool makes both readings explicit.

Related Number-Base Converter pages