The code below is converting big binary string binaryAsString = "1010101011101011......."
to BigInteger
decimal but this is very slow, it takes very long time to finish. Is there any faster way to make this done? Before this I had a problem with converting BitArray
to string
. My first code take so long but I found new code which was much faster in a way I didn't imagine. I hope I can find a similarly faster way to do this, because it's really taking a long time.
I tried to use String whatever = Convert.ToString(binaryAsString, 2);
but this is not working at all.
// converting the binary String to decimal
BigInteger Decimalvalue = 0;
foreach (char c in binaryAsString)
{
Decimalvalue <<= 1;
Decimalvalue += c == '1' ? 1 : 0;
}
I would like to have faster code to do exactly what the code above should do.