Binary To Decimal
This algorithm converts binary numbers to decimal numbers.
public static int BinaryToDecimal(string bin)
{
int binLength = bin.Length;
double dec = 0;
for (int i = 0; i < binLength; ++i)
{
dec += ((byte)bin[i] - 48) * Math.Pow(2, ((binLength - i) - 1));
}
return (int)dec;
}
Example
string data = "10111101011011010111110";
int value = BinaryToDecimal(data);
Output
6207166