CONVERTING FROM HEXADECIMAL TO DECIMAL

From WikiEducator
Jump to: navigation, search

Converting from Hexadecimal to Decimal

Steps:

  1. Get the last digit of the hex number, call this digit the currentDigit.
  2. Make a variable, let's call it power. Set the value to 0.
  3. Multiply the current digit with (16^power), store the result.
  4. Increment power by 1.
  5. Set the the currentDigit to the previous digit of the hex number.
  6. Repeat from step 3 until all digits have been multiplied.
  7. Sum the result of step 3 to get the answer number.

Example 1 - Convert the number 1128 HEXADECIMAL to DECIMAL

  1. 8 x (16^0) = 8 - Start from the last digit of the number. In this case, the number is 1128. The last digit of that number is 8. Note that the power of 0 of any number is always 1
  2. 2 x (16^1) = 32 - Process the previous, which is 2. Multiply that number with an increasing power of 16.
  3. 1 x (16^2) = 256 - Process the previous digit, which is 1, note that 16^2 means 16 x 16
  4. 1 x (16^3) = 4096 - Process the previous digit, which is 1, note that 16^3 means 16 x 16 x 16
Here, we stop because there's no more digit to process
Answer: 4392 - This number comes from the sum of the RESULTS (8+32+256+4096)=4392

Once discerned, notice that the above process is essentially performing this calculation:

1x(16^3) + 1x(16^2) + 2x(16^1) + 8x(16^0)

When doing this by hand, it is easier to start backward is because:

  • Counting the number of digits takes extra time, and you might count wrongly.
  • If you don't remember what a particular value of a power-of-16 is, it's easier to calculate it from the previous power value. For instance, if you don't remember what the value of 16^3 is, then just multiply the value of 16^2 (which you'll likely already have if you started backward) with 16.


Reference

CONVERTING HEXADECIMAL TO DECIMAL