Two's Complement Calculator
Convert signed decimal values or binary bit patterns to 4-, 8-, 16-, or 32-bit two's complement representations.
Examples: -5 or 0b11111011
About two's complement
Two's complement examples
| Decimal and width | Binary pattern | Explanation |
|---|---|---|
| -5 at 8 bits | 11111011 | Invert 00000101 and add one. |
| -8 at 4 bits | 1000 | This is the minimum signed four-bit value. |
| 42 at 8 bits | 00101010 | Positive values use ordinary padded binary. |
How to use the two's complement calculator
- Enter a signed decimal integer or a binary pattern with a 0b prefix.
- Choose the bit width used by the target system.
- Select Calculate two's complement.
- Compare the binary, signed decimal, and unsigned decimal interpretations.
Two's complement FAQ
Why does bit width matter?
The width determines the modulus and signed range. The same number has different padding and may not fit at a smaller width.
What range fits in eight bits?
An eight-bit two's complement integer ranges from -128 to 127. Its unsigned bit pattern ranges from 0 to 255.
How do I negate a binary number?
Within a fixed width, invert every bit and add one. Applying the process again returns the original value except for the minimum representable integer.
Why are signed and unsigned results different?
They assign different positional meaning to the highest bit. The stored bits are identical, but the interpretation changes.
Does two's complement have negative zero?
No, it has one all-zero representation for zero. This is an important advantage over sign-magnitude and one's complement systems.