TutorChase logo
Login
OCR GCSE Computer Science Notes

2.4.1 Conversions Between Denary, Binary, and Hexadecimal

Understanding how to convert between denary, binary, and hexadecimal is essential for interpreting and manipulating data in computer systems.

Denary and Binary Conversion

Binary numbers use only two digits: 0 and 1. Each binary digit (bit) represents an increasing power of 2, starting from the right.

Converting Denary to Binary

To convert a positive denary (decimal) number between 0 and 255 into binary:

  1. Identify the largest power of 2 less than or equal to the number.

  2. Subtract that value and place a 1 in that position.

  3. Continue with the remainder, moving down to smaller powers of 2.

  4. Fill in unused powers with 0.

Example: Convert 156 to binary:

  • 128 fits into 156 → 1 (156 - 128 = 28)

  • 64 does not fit → 0

  • 32 does not fit → 0

  • 16 fits into 28 → 1 (28 - 16 = 12)

  • 8 fits into 12 → 1 (12 - 8 = 4)

  • 4 fits into 4 → 1 (4 - 4 = 0)

  • 2 does not fit → 0

  • 1 does not fit → 0

Result: 10011100

Key Points for Denary to Binary

  • Always work from the highest power of 2 downward.

  • Resulting binary number should be up to 8 bits for numbers between 0 and 255.

  • Add leading zeros if necessary to reach 8 bits for clarity.

Example: 5 in binary = 00000101

Converting Binary to Denary

To convert binary back into denary:

  1. Write down the powers of 2 for each bit position.

  2. Add the values where there is a 1.

Example: Convert 01010110 to denary:

  • Positions with 1s: 64, 16, 4, 2

  • Add them: 64 + 16 + 4 + 2 = 86

Tips for Binary to Denary

  • Always check from left (most significant bit) to right (least significant bit).

  • Powers of 2 double as you move left: 1, 2, 4, 8, 16, 32, 64, 128.

Denary and Hexadecimal Conversion

Hexadecimal (hex) is base-16, using digits 0–9 and letters A–F (where A = 10, B = 11, ..., F = 15).

Converting Denary to Hexadecimal

Steps to convert denary to hexadecimal:

  1. Divide the denary number by 16.

  2. The quotient is the first hex digit.

  3. The remainder is the second hex digit.

Example: Convert 200 to hexadecimal:

  • 200 ÷ 16 = 12 remainder 8

  • 12 = C in hex

  • 8 remains 8

Result: C8

Important Details

  • Ensure hex results are 2 digits (00 to FF).

  • Values 10–15 are replaced with A–F.

Hex digits:

  • 10 → A

  • 11 → B

  • 12 → C

  • 13 → D

  • 14 → E

  • 15 → F

Converting Hexadecimal to Denary

Steps to convert hex to denary:

  1. Multiply the first hex digit by 16.

  2. Add the value of the second hex digit.

Example: Convert 3F to denary:

  • 3 × 16 = 48

  • F = 15

  • 48 + 15 = 63

Helpful Hints

  • Always know what letter corresponds to which value (A=10, B=11, etc.).

  • 2-digit hex numbers cover denary values from 0 to 255.

Binary and Hexadecimal Conversion

Binary and hexadecimal are closely linked because one hex digit represents exactly four binary bits.

Converting Binary to Hexadecimal

Steps to convert binary to hexadecimal:

  1. Split the binary number into groups of 4 bits from the right. Add leading zeros if needed.

  2. Convert each 4-bit group into a hex digit.

Example: Convert 11010111 to hexadecimal:

  • Split into groups: 1101 and 0111

  • 1101 = 13 = D

  • 0111 = 7 = 7

Result: D7

Key Reminders:

  • Group from right to left.

  • Add leading zeros to complete groups of 4 if necessary.

Example: 1010 → 0A if explicitly needing 2 hex digits.

Converting Hexadecimal to Binary

Steps to convert hexadecimal to binary:

  1. Convert each hex digit into its 4-bit binary equivalent.

Example: Convert 9A to binary:

  • 9 → 1001

  • A → 1010

Result: 10011010

Useful Tips

  • Memorize binary equivalents for hex digits:

    • 0 → 0000

    • 1 → 0001

    • 2 → 0010

    • 3 → 0011

    • 4 → 0100

    • 5 → 0101

    • 6 → 0110

    • 7 → 0111

    • 8 → 1000

    • 9 → 1001

    • A → 1010

    • B → 1011

    • C → 1100

    • D → 1101

    • E → 1110

    • F → 1111

Working with 1 to 8 Bits

Understanding Bit Ranges

Binary numbers used in conversions must contain between 1 and 8 bits. Some examples:

  • 1 bit: 1 (denary 1)

  • 4 bits: 1010 (denary 10)

  • 8 bits: 11001010 (denary 202)

When dealing with binary numbers, it is important to recognize that:

  • Missing bits on the left are treated as leading zeros.

  • An 8-bit binary number can represent numbers between 0 and 255.

Significance of Leading Zeros

Leading zeros are often added for clarity and uniformity:

  • 101 → 00000101

  • 11 → 00000011

Leading zeros do not change the value of the number but help in consistency when working with 8-bit systems.

Practical Examples

Example 1: Denary to Binary to Hexadecimal

Convert denary 222 to binary and hexadecimal:

  • Denary to Binary:

    • 222 - 128 = 94 → 1

    • 94 - 64 = 30 → 1

    • 30 - 32 = not possible → 0

    • 30 - 16 = 14 → 1

    • 14 - 8 = 6 → 1

    • 6 - 4 = 2 → 1

    • 2 - 2 = 0 → 1

    • 0 - 1 = not possible → 0

Binary: 11011110

  • Binary to Hexadecimal:

    • Split: 1101 1110

    • 1101 = D, 1110 = E

Hexadecimal: DE

Example 2: Hexadecimal to Binary to Denary

Convert hexadecimal 7F to binary and denary:

  • Hexadecimal to Binary:

    • 7 → 0111

    • F → 1111

Binary: 01111111

  • Binary to Denary:

    • 64 + 32 + 16 + 8 + 4 + 2 + 1 = 127

Common Mistakes to Avoid

  • Not padding binary numbers to 8 bits when needed.

  • Misinterpreting hex letters (e.g., thinking A = 11).

  • Skipping leading zeros when splitting binary into groups of 4 bits for hex conversion.

  • Wrong direction when matching powers of 2 during denary-binary conversions.

Always double-check your work, especially when converting large numbers close to the 255 limit. Familiarity with the powers of 2 and hex values will improve accuracy and speed.

FAQ

If you attempt to convert a denary number greater than 255 into 8-bit binary, you will not be able to represent the number accurately because 8 bits can only store values between 0 and 255. The largest value with 8 bits is 11111111, which equals 255. Any number beyond that requires more bits. For example, 256 would need 9 bits: 100000000. In computer systems where a fixed number of bits are used, trying to store a larger value can cause overflow, where excess bits are lost, leading to incorrect results or system errors. This is why memory size and bit limits are crucial in designing programs. In exams, you must recognize that numbers above 255 cannot be represented in 8 bits and would cause overflow or require more storage capacity, such as 9 bits or even 16 bits depending on the range of values the system must handle.

Hexadecimal numbers are used because they are a more compact and readable way of representing binary data. Every single hexadecimal digit represents exactly four binary digits (bits), so longer binary sequences can be grouped into much smaller, simpler hex numbers. For example, the 8-bit binary number 11010111 is much easier to read when written as D7. This efficiency reduces errors when reading, writing, or debugging code and helps programmers quickly identify patterns or mistakes. Hexadecimal is especially useful in computer memory addresses, color codes in web design, machine code, and low-level programming. Reading binary strings directly would be time-consuming and prone to mistakes, but hexadecimal’s shorter form preserves all the information with much less visual clutter. Therefore, hexadecimal acts as a bridge between human understanding and machine-level binary data, improving both clarity and communication without losing any of the original binary information.

To quickly estimate the size of a binary number compared to a denary value, look at its most significant bit (MSB), which is the leftmost bit. If the MSB is 1, the number is greater than or equal to 128 (since the leftmost bit represents 128 in an 8-bit number). If the MSB is 0, the number is less than 128. Additionally, counting how many bits are set to 1 also helps; more 1s typically mean a larger number. For example, 01111111 is just under 128, while 11111111 is 255. Another quick trick is noticing patterns: a binary number starting with several 1s (like 1110...) is likely in the higher range (above 200), whereas a number starting with many 0s (like 0001...) is in the lower range (below 32). This rapid evaluation is especially helpful when troubleshooting or estimating without needing full conversion.

Yes, it is entirely possible to have leading zeros in both binary and hexadecimal numbers, and they do not change the value of the number. Leading zeros are often added to make the length of a number match a required format, such as fitting an 8-bit binary structure or ensuring a 2-digit hexadecimal format. For example, binary 00001010 is the same as 1010, and hexadecimal 0A is the same as A. The leading zeros serve practical purposes: they improve readability, maintain consistent lengths for easier grouping, and help systems process data without confusion. In networking, for instance, fixed-length representations are vital to ensure correct data transmission. In exams or programming, it’s essential to recognize that leading zeros do not alter the mathematical value but might still be necessary for format requirements or clarity. Ignoring them when interpreting value is correct, but removing them when formatting could sometimes cause mistakes.

When converting binary numbers shorter than 8 bits into hexadecimal, you first pad the binary number with leading zeros to make its total length a multiple of 4. This is because each hex digit represents 4 binary bits. If you have 6 bits like 101010, you would add two leading zeros, making it 00101010. You then split it into groups: 0010 (2) and 1010 (A), resulting in 2A in hexadecimal. Padding ensures that no confusion occurs in grouping and that all information is captured accurately. Without padding, binary groups would be uneven, leading to errors during conversion. Padding does not change the value of the binary number—it simply formats it for proper translation. This step is essential especially in systems where memory is tightly controlled or when precise formatting is required, such as in communication protocols or graphical data representations. Always pad before you group to avoid conversion mistakes.

Practice Questions

A denary number is given as 213. Show how to convert this number into binary and hexadecimal.

To convert 213 to binary, find the highest power of 2 less than or equal to 213. 128 fits, so put a 1. 213-128=85. 64 fits into 85, so another 1. 85-64=21. 32 does not fit, so a 0. 16 fits into 21, so 1. 21-16=5. 8 does not fit, so 0. 4 fits into 5, so 1. 5-4=1. 2 does not fit, so 0. 1 fits, so 1. The binary is 11010101. To convert to hexadecimal, split into 1101 and 0101. 1101 is D, 0101 is 5. Thus, 213 in hexadecimal is D5.

Explain how to convert the hexadecimal number 9C into a binary number and a denary number.

To convert hexadecimal 9C to binary, convert each digit to its 4-bit binary form. 9 becomes 1001 and C becomes 1100, giving 10011100. To convert hexadecimal 9C to denary, first convert 9 and C to their denary equivalents: 9 is 9, and C is 12. Multiply 9 by 16 (9 × 16 = 144) and add 12 (144 + 12 = 156). Therefore, 9C in denary is 156. It is essential to handle each hexadecimal digit separately when converting to binary and to multiply correctly when converting to denary.

Hire a tutor

Please fill out the form and we'll find a tutor for you.

1/2
Your details
Alternatively contact us via
WhatsApp, Phone Call, or Email