Converting Between Denary & Binary (OCR GCSE Computer Science): Revision Notes
📚 Revision Notes
Converting Between Denary & Binary
Key Concepts
- Denary (Decimal): The number system we use every day, with digits from 0 to 9.
- Binary: A number system used by computers, consisting of only two digits: 0 and 1.
Binary Ranges
- Binary numbers up to 8 bits can range from 00000000 (which is 0 in denary) to 11111111 (which is 255 in denary).
Significant Bits
- Most Significant Bit (MSB): The bit furthest to the left. It holds the largest value.
- Least Significant Bit (LSB): The bit furthest to the right. It holds the smallest value.
Converting Denary to Binary (up to 8 bits)
Step-by-Step Explanation
To convert a denary number (0-255) to binary, you will use a table. Here's how to do it.
- Draw a table like this: | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | |---|---|---|---|---|---|---|---| | | | | | | | | |
Each number at the top is the value of that column. We're going to figure out if the denary number can fit into these values.
- Start from the left (128) and ask: Can the denary number fit into this value? If yes, write a 1 and subtract that value from the denary number. If no, write a 0.
- Move to the next column.
Example: Convert 56 to Binary
- Is 56 larger than or equal to 128? No, so put 0 under 128.
- Is 56 larger than or equal to 64? No, so put 0 under 64.
- Is 56 larger than or equal to 32? Yes, so put 1 under 32. Now subtract 32 from 56. The remainder is 24.
- Is 24 larger than or equal to 16? Yes, so put 1 under 16. Subtract 16 from 24. The remainder is 8.
- Is 8 larger than or equal to 8? Yes, so put 1 under 8. Subtract 8 from 8. The remainder is 0.
- Is 0 larger than or equal to 4, 2, or 1? No, so put 0 under 4, 2, and 1.
Here's how the table looks:
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 1 | 1 | 1 | 0 | 0 | 0 |
So, 56 in binary is 00111000.
Explanation
- Each 1 in the binary number means the denary number is large enough to fit in that column. Each 0 means it's too small.
- The answer 00111000 tells the computer how to store the number 56 in a way it understands.
Converting Binary to Denary
Step-by-Step Explanation
To convert from binary to denary, you do the opposite. Use a table, place each binary digit into its column, and then add up the values of the columns with a 1.
Example: Convert 01010101 to Denary
-
Write out the binary digits in the table: | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | |---|---|---|---|---|---|---|---| | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 |
-
Look at the columns with a 1. Add those values:
- 64 (from the 1 under 64)
- 16 (from the 1 under 16)
- 4 (from the 1 under 4)
- 1 (from the 1 under 1) So, 64 + 16 + 4 + 1 = 85.
Answer: 01010101 in denary is 85.
Explanation
- Each time you see a 1 in a column, that means that value is included in the number. Adding up those values gives you the denary number.
Dealing with Shorter Binary Numbers
- Binary numbers can have less than 8 bits. For example, 11010 is only 5 bits long.
- To make it easier to work with, you can add leading zeros to make it 8 bits: 00011010. This helps keep things clear when comparing or converting.
infoNote
Final Tips
- Always work from the largest value (leftmost column) to the smallest value (rightmost column) when converting denary to binary.
- When converting binary to denary, just add up the values where there's a 1.
- Use leading zeros for binary numbers with fewer than 8 bits to make them easier to handle.
Quick Reference Conversion Table
| Denary | Binary | Hexadecimal |
|---|---|---|
| 0 | 00000000 | 00 |
| 56 | 00111000 | 38 |
| 85 | 01010101 | 55 |
| 255 | 11111111 | FF |