Making of the: Decimal to Binary Calculator

The decimal to binary converter’s output is the most complicated decimal to * converter output to format. This converter toke the second most time to develop behind the hexadecimal to decimal converter.

The procedure begins with getting the users input. I began by using a logarithmic function (the reverse of a exponent function) to get largest exponent of two(2) that is still less than the user input that we will call x (e.g. for the input 6 x would be 2 while 100 x would be 6). Next depending on what x is I would begin the string that will eventually output with a certain number of zeros (e.g. initially add 1 to x then if x is less than 8 I would add 8 – x zeros to the string but if x is greater than 8 I would add 16 – x zeros). After adding the necessary zeros, the next step is to start loop that ends when x is zero (0) with each iteration of the loop taking one away from x. In the loop I check if the user input minus x to the power of 2 is greater than or equal to zero (0), if it is then a “1” is added to the string formerly containing only zeros. When the result is less than zero (0) a “0” is added to the string .After the loop is I output the completed 8-bit string.