I need a function like
int GetIntegerFromBinaryString(string binary, int bitCount)
if binary = “01111111” and bitCount = 8, it should return 127
if binary = “10000000” and bitCount = 8, it should return -128
The numbers are stored in 2’s complement form. How can I do it. Is there any built in functions that would help so that I needn’t calculate manually.
here you go.
Convert it to the 2-s complement version of a 32 bit number, then simply let the Convert.ToInt32 method do it’s magic.