When converting Decimal numbers to Hexadecimal numbers in Java you would follow the basic algorithm that would convert a different base number to a decimal number.
This algorithm is to divide the number by the base you are converting to and then take the remainder and quotient. The remainder is the last character of the number being converted to. The quotient is now divided again by the desired base. and the remainder is added to the front of the character before it. And then the process repeats.
Example:
50 to hexadecimal
50 / 16 = 3 r 2
3 / 16 = 0 r 3
and so the hexadeciaml equivalent would be 32
In hexadecimal this algorithm applies, but remember when the remainder is over 9 change to character values.












One Response
This is genius.