Denary to Binary Conversion
To turn a denary number into unsigned 8-bit binary, you can use the place-value method: compare the number with each binary place value from largest to smallest, deciding one bit at a time.
Write 128, 64, 32, 16, 8, 4, 2 and 1 in a row. Each value is double the one on its right, and between them they cover every whole number from 0 to 255.
| Place value | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|
| Bit | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 1 |
| Amount left | 89 | 25 | 25 | 9 | 1 | 1 | 1 | 0 |
At each place, ask whether that place value fits into the amount you still have left.
Take 89. 128 is too big, so write 0. 64 fits, so write 1 and 89 − 64 = 25. 32 is too big: 0. 16 fits: 1, leaving 9. 8 fits: 1, leaving 1. Then 4 and 2 are too big: 0 and 0. Finally 1 fits: 1, leaving 0. Reading across gives 01011001.
The subtraction is what keeps the running total right. Writing a 1 without subtracting would set extra bits and push the total past the number you started with.
Once the amount left reaches zero, fill every remaining place to the right with 0 so that the answer is exactly eight bits, even when those bits add nothing.
Eight bits give 256 different patterns, so an unsigned 8-bit number holds the values 0 to 255. Zero uses every bit at 0, so it is 00000000. 255 needs every place value: 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255, so all eight bits are 1 and it is 11111111. A denary number above 255 needs a ninth bit, so it cannot be stored in an unsigned 8-bit number at all.
Edexcel GCSE Computer Science · Denary to Binary Conversion
Edexcel GCSE Computer Science · Denary to Negative Binary Conversion