The program to convert the given binary number into a decimal number is discussed here. For example, the decimal equivalent of the binary number 1111 is 15.
Consider the binary number from the last.nnFor the above mentioned example,nn1 * 2^0 = 1n1 * 2^1 = 2n1 * 2^2 = 4n1 * 2^3 = 6nnDecimal number = 1 + 2 + 4 + 6 = 15nn1111 in binary form is represented as 15 in decimal.n
@@coding::1@@
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.
A program to convert numbers from binary numbers of higher range to decimal is given below
@@coding::2@@
Recommended Programs