Two's complement is the standard way computers represent signed integers. The leftmost bit is the sign: 0 = positive, 1 = negative.
Binary (two's complement)
—
—
—
Why two's complement?
Two's complement makes subtraction trivial for hardware — a computer only ever adds.
One zero
Unlike sign-magnitude, two's complement has a single representation of zero — no messy +0/−0.
Natural wraparound
Adding 1 to the largest value wraps to the most negative — a built-in modulo system.
Simple negation
To negate: invert every bit, then add 1. Try it on −42: invert 42's bits and add 1.
Range by bit width
The representable range depends on how many bits you use.
- • 8-bit — from −128 to +127.
- • 16-bit — from −32,768 to +32,767.
- • 32-bit — from −2,147,483,648 to +2,147,483,647.
- • Formula — range is −2^(n−1) to 2^(n−1)−1.
More developer tools
Explore binary, RAID and screen-size calculators in our tech toolkit.
Browse All Tools