2’s complement (cont’d)
Wow, this works! We can add numbers without thinking about their sign! Let’s do this in binary.
Example with 4 bits. Instead of using decimal 100 as 0 mark, we use binary 10000. So -I is represented by 10000 - I. Everything is the same just that we do things in binary.
Shortcut for computing 2’s complement.
- 10000 - I = (1111 + 1) - I = (1111 - I) + 1
- What does 1111 - A mean? It’s the same as inverting...
- So, to take 2’s complement: invert bits and add 1.