Two's complement
The way computers store negative integers: flip the value's bits and add 1. It has a single zero and lets you subtract by adding.
Example
−5 in 8 bits: 5 is 0000 0101, flipped 1111 1010, plus 1: 1111 1011. And 5 + (−5) gives 0.
Test yourself: Two's complement
How numbers are stored
A two's complement byte goes from −128 to ___.
That's 256 values: 128 negatives, 0 and 127 positives. The pattern 1000 0000 is used for −128.
How numbers are stored
With two's complement, subtraction a − b is done as the addition a + ___.
7 − 3 is 7 + (−3): 0000 0111 + 1111 1101 = 1 0000 0100, the 9th bit is dropped and you get 0000 0100, that is 4.
0/2
â–¶ Play