
Short answer
To get the two's complement of a number, flip every bit and add 1. In 8 bits, −5 is 11111011. The top bit is the sign, and an 8-bit signed value ranges from −128 to 127.
1. The rule
- 1Write the positive number in binary: 5 = 00000101.
- 2Flip every bit: 11111010.
- 3Add 1: 11111011. That is −5.
2. Reading a negative value
If the top bit is 1, flip all bits and add 1 to get the magnitude. 11111011 flips to 00000100, plus 1 is 00000101 = 5, so the value is −5.
3. 8-bit patterns worth knowing
| Pattern | Value |
|---|---|
| 01111111 | 127 |
| 00000000 | 0 |
| 11111111 | −1 |
| 11111011 | −5 |
| 10000000 | −128 |
4. Signed ranges
| Word size | Signed range |
|---|---|
| 8-bit | −128 to 127 |
| 16-bit | −32,768 to 32,767 |
| 32-bit | −2,147,483,648 to 2,147,483,647 |
| 64-bit | −9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 |
5. Subtraction by addition
7 − 5 becomes 7 + (−5): 00000111 + 11111011 = 1 00000010. Drop the carry out of the top bit and you have 00000010, which is 2.
6. Why it is used
The same adder circuit handles signed and unsigned values, and there is only one zero. Enter any value in the two's complement mode of the Binary Calculator to see each step. Related: binary conversion chart.
7. Frequently asked questions
How do you find two's complement?expand_more
Flip every bit, then add 1.
What is -5 in 8-bit binary?expand_more
11111011.
What is the range of an 8-bit signed number?expand_more
-128 to 127.
Why is there only one zero in two's complement?expand_more
Flipping 00000000 and adding 1 returns 00000000, so negative zero does not exist.
8. Sources
- menu_bookTwo's complement (Wikipedia)