my byte array has these first 8 values,
0 0 12 12
0 0 127 224
However when I read the bitarray after conversion,
it has,
0000,0000 0000,0000 0011,0000 0011,0000
0000,0000 0000,0000 1111,1110 0000,0111
I have no idea why bitarray have these values…
ANybody knows why this is happening?
Code used for the conversion is;
byte[] bytes = System.IO.File.ReadAllBytes(args[0]);
BitArray bits = new BitArray(bytes);
All the bits need to be read from right to left in order to make sense.
0000,0000
0000,0000
0011,0000 –> 00001100 = 12
0011,0000
0000,0000
0000,0000
1111,1110 –> 01111111 = 127
0000,0111
That’s just the way the BitArray works.
http://msdn.microsoft.com/en-us/library/x1xda43a.aspx
So the least significant bit of the first byte in the array is bit 0 in the bit array and the second least significant bit of the first byte in the array is bit 1 in the bit array.
I have no idea why they did it that way.