Decimal & Hexadecimal Conversion Quest

Decimal & Hexadecimal Conversion Quest

Mastering the Hex Code!

Hey aspiring coder! This quiz is your chance to become fluent in another secret computer language: Hexadecimal (or "Hex" for short)! Computers love hex because it's a super-efficient way to represent binary code in a way that's easier for humans to read.

You'll learn to switch between our everyday numbers (decimal/denary) and these powerful hex codes. This skill is vital for understanding memory addresses, color codes in web design, and even low-level programming!

Ready to Decode Hex? Here’s How:

Let's Learn How to Convert Decimal & Hexadecimal!

Before you start the quiz, let's go through examples for both types of conversions. Understanding these steps is key!

Example 1: Convert Decimal (181) to Hexadecimal.

Walkthrough:

We use "repeated division by 16" and note the remainders (just like decimal to binary, but with 16!).

  1. Divide by 16:

    Divide your decimal number by 16. Note the whole number result (quotient) and the leftover (remainder).

    For 181:

    • 181 ÷ 16 = 11 with a remainder of 5
    • Take the new number, 11: 11 ÷ 16 = 0 with a remainder of 11

    You stop when the result of your division becomes 0.

  2. Convert Remainders to Hex Digits:

    Convert any remainders greater than 9 to their hexadecimal letter (A=10, B=11, C=12, D=13, E=14, F=15).

    • Remainder 5 is still 5 in hex.
    • Remainder 11 is B in hex.
  3. Read Upwards:

    Read your hex digits from bottom to top (the last remainder you found is the first digit of your hex number).

    B (from last step)
    5 (from first step)

    Putting them together, you get: B5.

So, the decimal number 181 is B5 in hexadecimal!

Example 2: Convert Hexadecimal (B5) to Decimal.

Walkthrough:

To convert from hexadecimal back to decimal, we use place values (powers of 16).

  1. Identify Place Values:

    Starting from the rightmost digit, each position has a value that increases by a power of 16 as you move left:

    • Rightmost digit: 1s place (16 to the power of 0, or 160)
    • Second from right: 16s place (16 to the power of 1, or 161)
    • Third from right: 256s place (16 to the power of 2, or 162)
    • And so on...
  2. Convert Hex Digits to Decimal Values:

    Remember that hex letters A-F need to be converted back to their decimal equivalents first (A=10, B=11, etc.).

    For our example, B5:

    • The 'B' is at the 16s place. 'B' is 11 in decimal. So, 11 × 16 = 176.
    • The '5' is at the 1s place. '5' is 5 in decimal. So, 5 × 1 = 5.
  3. Add the Results:

    Finally, add up all the calculated values:

    176 + 5 = 181.

    So, B5 in hexadecimal is 181 in decimal!