Program to convert the given binary number into decimal number is discussed here. For example, the decimal equivalent of binary number 1111 is 15.
Consider the binary number from the last. For the above mentioned example, 1 * 2^0 = 1 1 * 2^1 = 2 1 * 2^2 = 4 1 * 2^3 = 6 Decimal number = 1 + 2 + 4 + 6 = 15 1111 in binary form is represented as 15 in decimal.
The above program works only with binary numbers given in the range of integers (-32767 to 32767). To work with long binary numbers (greater range of numbers with 20 bits or 30 bits), a string variable is used to store the binary numbers.
Program to convert numbers from binary numbers of higher range to decimal is given below