How the conversion works
Each binary digit represents a power of 2, starting from 2 to the power 0 on the right. Multiply each bit by its positional value and sum all the products to get the decimal result.
For example, binary 1101 equals 1 times 8 plus 1 times 4 plus 0 times 2 plus 1 times 1, which gives decimal 13.
decimal = sum of (bit_i * 2^i)
Each bit is multiplied by 2 raised to its position index, starting from 0 on the right.