Making of the: Hexadecimal to Decimal Calculator

The hexadecimal to decimal converter was the most difficult of the six (6). I had to take into account fifteen (15) different character options when converting to decimal. Along with this, procedures also changed depending on the length of hexadecimal value entered.

The procedure begins like the octal to decimal converter with getting the users input and as always when converting to decimal it is stored in a character array. Now if the input is more than one (1) character long, we take the first character and convert it to decimal (e.g. 3 equals 3 and f equals 15). We then take that number and multiply it by sixteen (16) to the power of the length of the input minus one (1) to give us a value we’ll call x. If the input were “30” this first step would give us 48 which since the only other character us “0”, x would be the final answer. If any other character is not “0” we would repeat this step and add the new value to x. If the input were “31” the final value would be 31 (3 = 48 and 1 = 1).
In the case of the input being only one character long the procedure is more simple. The only step is to convert the input value to decimal (e.g. 3 equals 3 and f equals 15) and this would be the final answer.

Making of the: Octal to Decimal Calculator

The octal to decimal converter was a step above the binary to decimal converter in terms of difficulty. I had the least interest in this converter as I never use octal but the procedure which was new to me kept my interest.

The procedure begins with getting the users input and storing in a character array. Now if the input is more than one (1) character long, we take the first character and convert it to decimal (e.g. 3 equals 3 and 8 equals 8). We then take that number and multiply it by eight (8) to the power of the length of the input minus one (1) to give us a value we’ll call z. If the input were “10” this first step would give us 8 and since the only other character us “0”, x would be the final answer. If any other character is not “0” we would repeat this step and add the new value to x continuously until we run out of characters. If the input were “12” the final value would be 10 (1 = 8 and 2 = 2).
In the case of the input being only one character long the procedure is more simple. The only step is to convert the input value to decimal (e.g. 3 equals 3 and 8 equals 8) and this would be the final answer.

Making of the: Binary to Decimal Calculator

The binary to decimal converter is the most simple converter out of the six (6). In less than thirty (30) lines it in converter any binary value to decimal.

The procedure begins with getting the users input and storing in a character array. Now whether or not the input is more than one (1) character long, we take the first character and convert it to decimal (e.g. 0 equals 0 or 1 equals 1). We then take that number and multiply it by two (2) to the power of the length of the input minus one (1) to give us a value we’ll call z. If the input were “100” this first step would give us 4 and since the only other character us “0”, x would be the final answer. If any other character is not “0” we would repeat this step and add the new value to x continuously until we run out of characters. If the input were “101” the final value would be 5 (1 = 4, 0 = 0 and 1 = 1).

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.

Making of the: Decimal to Octal Calculator

The decimal to octal converter is a lot like the decimal to binary converter at the beginning. This converter was a good preparation for the decimal to hexadecimal converter as it followed a similar form.

The procedure begins with getting the users input. Like the decimal to binary converter before I used a logarithmic function to get largest exponent of eight (8) that is still less than the user input that we will call x (e.g. every number that is greater than 8 and less than 64 would return 1). 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 8 in integer form which is then converted to a string. After the loop is finished I combine these value into one and output it.