Two's complement
- 0 represents a positive number
- 1 represents a negative number
- To convert a negative number to a positive number, you must:
- Flip the binary bits, which also flips the most significant bit (MSB)
- Add 1
Here is 75 converted to a negative:
MSB | 64 | 32 | 16 | 8 | 4 | 2 | 1 | Value |
0 | 1 | 0 | 0 | 1 | 0 | 1 | 1 | 75 |
Flip the bits
MSB | 64 | 32 | 16 | 8 | 4 | 2 | 1 | Value |
1 | 0 | 1 | 1 | 0 | 1 | 0 | 0 | -76 |
Add a 1
MSB | 64 | 32 | 16 | 8 | 4 | 2 | 1 | Value |
1 | 0 | 1 | 1 | 0 | 1 | 0 | 1 | -75 |