number = 247 247 div 16 = 15 r 7 so digit[ 0 ] = 7 number = 15 15 div 16 = 0 r 15 so digit[ 1 ] = F ("15" is in base 10, "F" is the hex digit) Result: 24710 = 0xF7
To
convert 247 from decimal to base 16,
repeatedly divide by 16, collecting the remainders in the base 16 expression.
This is shown above.
Check the result by converting the base 16 expression
to decimal:
The algorithm can be described as: Divide the number by the base. The remainder is the digit. The quotient becomes the number. Repeat. The digits come out right to left.
Here is another base conversion. Find pencil and paper and try it.
Convert 103310 to hex.