Making of the: Decimal to Hexadecimal Calculator

The decimal to hexadecimal converter is a lot like the previous two at the beginning but gets more complicated in the middle and the end. This converter was one of the more interesting ones to develop.

The procedure begins with getting the users input like the previous two and the next three. Like the decimal to binary and octal converters before I used a logarithmic function to get largest exponent of sixteen (16) that is still less than the user input that we will call x (e.g. for the input 30 x would be 1 while 257 x would be 2). Now I start a loop that ends when x is zero (0) with each iteration of the loop taking one away from x. During the loop I divide the user input by x to the power of 16 in integer form then match the integer with the corresponding hexadecimal value (e.g. 0 in hexadecimal is “0” whereas 14 is “E”). After the loop is finished I combine these value into one and output it.