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
Checking the result:
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.