In this section, we are going to write a code to convert binary string into a decimal number. To do this, we are going to use 2 to the power of n formula (2n) to get the decimal value. We will multiply the last digit of the binary digit with 20, then multiply the next binary digit with 21, and so on.
Let's use our binary digit from the previous section, which is 111110100, and convert it to a decimal number. Please see the following diagram to find out the answer:
We will get the decimal number by adding all the results of 2n multiplication. So, 256 + 128 + 64 + 32 + 16 + 0 + 4 + 0 + 0 equals 500.
Now, let's ...