Published: May 3, 2026 · 8 min read
The Problem
Computers only understand binary — ones and zeros. There's no minus sign in hardware. So how do processors represent negative numbers? The answer is two's complement, and it's one of the most elegant inventions in computer science.
How It Works
In two's complement, the most significant bit (MSB) acts as the sign bit: 0 = positive, 1 = negative. To negate a number, invert all bits and add 1.
For an 8-bit system:
• +5 = 00000101
• Invert: 11111010
• Add 1: 11111011 = −5
Range of Values
For n-bit two's complement:
• 8-bit: −128 to +127
• 16-bit: −32,768 to +32,767
• 32-bit: −2,147,483,648 to +2,147,483,647
Why Two's Complement is Genius
The beauty of two's complement is that addition works identically for both positive and negative numbers. The CPU doesn't need separate circuits for subtraction — it just negates one number and adds. This simplifies hardware enormously.
Example: 5 + (−3) = 2
• 00000101 (+5)
• + 11111101 (−3)
• = 100000010 → discard overflow bit → 00000010 = 2 ✓
Common Hex Values
• −1 (8-bit) = 0xFF
• −1 (16-bit) = 0xFFFF
• −1 (32-bit) = 0xFFFFFFFF
• −128 (8-bit) = 0x80
• +127 (8-bit) = 0x7F
Try Our Converter
Convert any decimal to two's complement with our Two's Complement Converter.