Calculate two's complement for binary numbers. Essential for understanding negative number representation in computer systems.
Original binary number:
Invert all bits (one's complement):
Add 1 to the inverted number:
Two's complement is a mathematical operation on binary numbers and the most common method of representing signed integers in computers. It solves the problem of negative number representation in binary systems.
Invert Bits
                            Change all 0s to 1s and all 1s to 0s
Add 1
                            Add 1 to the inverted number using binary addition
Result
                            The final number is the two's complement
| Bit Length | Minimum | Maximum | Range | 
|---|---|---|---|
| 4 bits | -8 | 7 | 16 numbers | 
| 8 bits | -128 | 127 | 256 numbers | 
| 16 bits | -32,768 | 32,767 | 65,536 numbers | 
| 32 bits | -2,147,483,648 | 2,147,483,647 | 4,294,967,296 numbers | 
Only one representation for zero (000...0)
Same circuit for addition and subtraction
No special cases for negative numbers
0101 → 1010 → 1011
+5 → -5
00000101 → 11111010 → 11111011
+5 → -5
1000 → 0111 → 1000
-8 → +8 → -8 (same)
                        English