Binary
In 8-bit two's complement every bit still has a place value, but the leftmost bit is worth -128 rather than 128. Reading left to right, the eight place values are -128, 64, 32, 16, 8, 4, 2 and 1. Any 1 bit adds its place value to the total; any 0 bit adds nothing.
| Bit position | Place value |
|---|---|
| 7 (leftmost, the sign bit) | -128 |
| 6 | 64 |
| 5 | 32 |
| 4 | 16 |
| 3 | 8 |
| 2 | 4 |
| 1 | 2 |
| 0 (rightmost) | 1 |
The leftmost bit is called the sign bit, and it really is part of the total. When it is 1 you start at -128; when it is 0 the value is zero or positive and you add only the ordinary values. A pattern with a 1 in the sign bit is always negative, because the other seven bits can add at most 64 + 32 + 16 + 8 + 4 + 2 + 1 = 127, which is never enough to climb back up to zero.
Write down each place value under its bit, then add the values wherever a 1 appears. Take 11010010: the 1s sit in the -128, 64, 16 and 2 columns, so the value is -128 + 64 + 16 + 2 = -46. Try 11100111: -128 + 64 + 32 + 4 + 2 + 1 = -25. Because the sign bit can never be cancelled out, any pattern that begins with 1 sits somewhere from -128 up to -1, and any pattern that begins with 0 sits from 0 up to 127, so a single byte holds exactly 256 different values, from -128 up to 127, with no gaps.
A 0 in the sign bit means the -128 card is not counted, so you just add the positive values. For 01000111 that is 64 + 4 + 2 + 1 = 71. This is exactly the same number you would get reading the pattern as unsigned, because positive two's complement patterns are never changed.
Two's complement is the method computers use to store negative whole numbers in binary. To turn a negative denary number into its 8-bit two's complement pattern, start from the positive version of the number and follow three steps: write the positive value in 8 bits, flip every bit, then add 1.
The flip on its own gives a pattern that is one less than the value you need: the flipped 9 is 11110110, which is -10, not -9, so the add-one step must come after the flip, never before. A quick check on your answer: a negative number always starts with a 1 in the leftmost bit, while a positive number starts with 0. You only use these steps for negative values, because a positive number's pattern is already correct as it stands.
| Step | 8-bit pattern |
|---|---|
| Positive 9 in binary | 00001001 |
| Flip every bit | 11110110 |
| Add 1 | 11110111 |
So -9 is stored as 11110111. A second run-through: positive 20 is 00010100, which flips to 11101011, and adding 1 gives 11101100 for -20.
An 8-bit two's complement pattern that begins with a 1 in the most significant bit (the sign bit) stands for a negative number. To turn it into denary, use flip the bits and add one: change every 0 to a 1 and every 1 to a 0, add 1 to what you get, read that as the positive size, then put a minus sign in front.
Take 11011001.
001001100010011111011001 represents -39.Stopping at 39 gives a positive answer, which is wrong: the pattern stores a negative value, so the minus sign is part of the answer, not an optional extra. Nor is the sign bit a marker sitting outside the number. It is a real bit with a place value of -128, which is why any pattern starting with 1 is worth less than zero.
The same two steps work the other way round: to find the pattern for a negative denary value, write its positive size in binary, flip every bit and add 1. Converting each way is a mirror image of the other, so the method never changes.
There is a shortcut for turning a negative denary number into 8-bit two's complement. It skips the add-one step and produces exactly the same pattern as flip-every-bit-then-add-1, so both routes earn the marks.
Positive 26 is 00011010. Reading from the right, the first 1 is the second bit from the right, so you copy 10 as it stands. The six bits to its left, 000110, all flip to 111001. Joining the two parts gives 11100110, so -26 is 11100110. You can check it the long way: 26 flips to 11100101, and adding 1 gives the same answer.
Another quick one: positive 9 is 00001001, so you copy the final 1, flip 0000100 to 1111011, and -9 is 11110111.
| Step | Flip all bits, then add 1 | Copy to the first 1, then flip |
|---|---|---|
| Start with 26 | 00011010 | 00011010 |
| Do the change | 11100101, then add 1 | keep 10, flip 000110 to 111001 |
| Result for -26 | 11100110 | 11100110 |
It works because adding 1 to the flipped pattern carries through the run of trailing 1s, turning them to 0s and the first 0 to their left into a 1. That restores the bits you copied — the trailing 0s and the first 1 — while everything to the left stays flipped. Only use it when converting a negative value: a positive number such as 26 keeps its plain binary pattern 00011010, with nothing flipped at all.