This is a very common task for a beginner programmer. Unfortunately many beginners do not seem to understand the question.

First, know that binary, decimal, octal, hexadecimal, and others are simply *representations* of values. The value of 123 (decimal) still has the same *value* if it represented in hexadecimal (7B), octal (173), or binary (1111011). So the first thing to know is that you are not converting a binary *value* to a decimal *value*.

What is the question then? You are likely being asked to convert the *text representation* of a value from binary notation into a value. So it is a conversion of text to an integral *value*.

Like each digit in 123 has place value (1 is in the hundreds place, 2 is in the tens place, and 3 is in the units place), each bit in a binary number has place value as well. Starting from the least significant bit, each next significant bit has twice the place value.

Okay, here's some code.