Most of the answers so far assume that the input is a list of integers representing the digits. As the original question didn't specify the form of the input, here some alternatives.
Taking a string as input
Of course the simplest way to turn a string of binary digits into a number is
fromBinary[s_String] /; StringMatchQ[s,RegularExpression["[01]+"]] :=
ToExpression["2^^" <> s]
(the complicated part here just checks that the string indeed contains a binary number).
However that would not involve an explicit summation (well, somewhere internally it probably does, but that's hidden), therefore I give another solution containing an explicit sum:
fromBinary[s_String] /; StringMatchQ[s,RegularExpression["[01]+"]] :=
Total[2^(StringLength[s]-StringPosition[s,"1"][[All,1]])]
The explicit sum is in the call of Total
which just adds up all elements in the list given to it.
Taking an integer as input
OK, now I'm assuming that the input is given as an integer whose decimal digits match the binary digits of the intended number (i.e. when given the number 1001
— that is, one thousand and one — it interprets it as the digit sequence 1
, 0
, 0
, 1
). Of course, given the function above, it's easy to do that (I omit the binary check here):
fromBinary[i_Integer] := fromBinary[IntegerString[i]]
Another alternative would be to use IntegerDigits[i]
and feed the result into the code given in the previous answers.