Binary to Denary Conversion
Binary numbers can be any length from 1 to 8 bits, but the place values 128, 64, 32, 16, 8, 4, 2 and 1 only give the right total when each bit sits in the correct column. A short number has to be padded — filled out with extra zeros on the left — before you convert it.
To pad a number, add zeros to the left-hand end until it is exactly 8 bits long. Padding never changes the value, because each new zero sits in a column whose place value you never add in. So 101101 becomes 00101101, and it is still the same number.
Once the number is 8 bits, the least significant bit (the rightmost bit) sits under the place value 1, and every bit to its left moves one place value up: 2, 4, 8 and so on. Bits are always lined up from the right, never from the left, because a bit is worth whatever place value it lands on when you count back from that right-hand 1. A short number lined up from the left lands on the big place values and comes out far too large.
A 6-bit reading from a greenhouse light sensor arrives as 101101. Convert it to denary. It has 6 bits, so pad it to 00101101 and write the place values above it:
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 1 | 0 | 1 | 1 | 0 | 1 |
The 1s are in the 32, 8, 4 and 1 columns, so the value is 32 + 8 + 4 + 1 = 45. Pushed up against the 128 column instead, those same bits would land on 128, 32, 16 and 4 and give 180.
That is why the leftmost bit of a short number is not worth 128: its place value depends on how many bits the number has. Only a full 8-bit number has 128 in its most significant bit position, and for 00101101 that column holds a 0 anyway.
Binary values are usually written as a full 8 bits, so the leading zeros you added stay in the answer.
OCR GCSE Computer Science · Binary to Denary Conversion
OCR GCSE Computer Science · Denary to Binary Conversion
OCR GCSE Computer Science · Hexadecimal to Binary Conversion
OCR GCSE Computer Science · Binary to Hexadecimal Conversion