Two's Complement Calculator
Convert signed decimals to two's complement binary/hex and back, with every step.
What it does
Two’s complement is how computers store negative integers. Convert a signed decimal to binary/hex, or decode binary back to decimal, with every step shown.
Where it's used
Embedded programming, reading sensor registers that hold signed values and computer-architecture courses.
How to use it
- Choose decimal → binary or binary/hex → decimal.
- Type the value.
- For decimal → binary, choose the bit width.
The formula explained
- −x
- (invert all bits of x) + 1
- MSB
- the top bit is the sign: 1 means negative
- Range
- −2ᴺ⁻¹ … 2ᴺ⁻¹ − 1 for N bits
Worked example
−100 stored in 16 bits.
Inputs:
- Convert: Decimal → two’s complement
- Value: -100
- Bit width: 16 bits
The calculator gives:
- Two's complement (binary): 1111 1111 1001 1100
- Signed decimal: -100
- Unsigned interpretation: 65436
Tips and common mistakes
- 8 bits hold −128 to 127; 16 bits hold −32 768 to 32 767.
- The same bits mean different numbers as signed or unsigned values.
- When widening a negative number, copy the sign bit (sign extension).
Questions people ask
How do I find the two’s complement by hand?
Write the positive number in binary, invert every bit and add 1. For −100 in 8 bits: 100 = 0110 0100 → 1001 1011 → 1001 1100, which is 0x9C.
What range do N bits hold?
From −2^(N−1) to 2^(N−1) − 1. That is −128 to 127 in 8 bits, −32 768 to 32 767 in 16 bits and about ±2.1 billion in 32 bits.
Why do computers use two’s complement?
Addition and subtraction work the same way for signed and unsigned numbers, so one adder serves both, and there is only one zero (unlike sign-and-magnitude, which has +0 and −0).
Related Digital Logic calculators
- Binary Calculator
- Number System Converter
- Logic Gate Calculator
- Parity Bit Calculator
- Hamming Code Calculator
- Truth Table Generator
- Karnaugh Map Solver
- Gray Code Converter
- Bitwise Calculator
- Bit Shift Calculator
Enter your values to get the result with the formula, substituted values and an explanation of each step.