Decimal to Hexadecimal Conversion
Positive Integers
The simplest way to convert unsigned numbers from decimal to hexadecimal is to transform the number first in binary, as the binary to hex conversion is trivial.
For instance:
9910 = 1*64 + 1*32 + 0*16 + 0*8 + 0*4 + 1*2 + 1*1 = 1*26 + 1*25 + 0*24 + 0*23 + 0*22 + 1*21 + 1*20.
9910 = 11000112
To convert a value from binary to hexadecimal, you first add a number of 0's to the left of the most significant bit of the binary number, so the
number of bits of the new binary number is a multiple of 4. Then, you simply translate each 4-bit binary nibble to its hexadecimal digit equivalent.
9910 = 11000112 = 0110 00112 = 0x63.