Well I'm confused this isn't easier than I thought... I want to convert a twos complement binary string to the appropriate number:
-5 = '11111011' according to Wikipedia
So I would think the following would return negative 5, but it doesn't. After reading Wikipedia it seems all I have to do is subtract one then invert the bits:
~(parseInt('11111011', 2) - 1)
But it returns -251. Confusing...
Please note that I will be dealing with many odd bit lengths and all won't be 8 bits.