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.

Leave a Reply

Your email address will not be published. Required fields are marked *