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).

Leave a Reply

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