- For in the range , it’s two’s complement negation is given by:
Performing the negation in binary form
There are two methods to do this.
- Complement the bits and increment the result by 1.
-x = ~x + 1
- Complement each bit that is to the left of rightmost 1
Example
| 5 [0101] | -6 [1010] | -5 [1011] |
| 7 [0111] | -8 [1000] | -7 [1001] |
| -4 [1100] | 3 [0011] | 4 [0100] |
| 0 [0000] | -1 [1111] | 0 [0000] |
| -8 [1000] | 7 [0111] | -8 [1000] |