Decimal and Hexadecimal Integer Conversions

Опубликовано: 12 Май 2026
на канале: Ed S.
479
0

Hexadecimal Values

0 through 9 are their usual value with A = 10, B = 11, C = 12, D = 13, E = 14, and F = 15.


Hexadecimal to Decimal conversion

1. Let H represent the hexadecimal integer.
2. Determine the number of digits of H. Let n be the number of digits.
Let D = 0.
3. Multiply the first digit of H by 16^(n-1) and add the result to D. Multiply the second digit of H by 16^(n-2) and add the result to D. Continue until you reach the last digit, where it is multiplied by 16^0 (which is 1).

Decimal to Hexadecimal Conversion

Let D be the decimal integer.

1. Determine the biggest power of 16 that equal to or less than D. Let n be that power. The number of digits of your answer will have n+1 digits.

If you have a scientific calculator, use the formula n=integer(ln D/ln 16).

2. Divide D by 16^n. Let Q be the quotient. This is your left-most digit. H is built from left to right.
3. Subtract 16^n*Q from D.
4. Subtract 1 from n.
5. If n is zero 0, stop. D represents your last digit. If n is not zero, repeat steps 2 through 4.