BitArray and Little Endian bit order of bytes

  • Thread starter Thread starter Laszlo Szijarto
  • Start date Start date
L

Laszlo Szijarto

In using the BitArray class to parse a single byte, I noticed that the bits
show up in Little Endian order. Aren't bits always arranged in Big Endian
order? I'm a bit confused and would appreciate any assistance.

Thank you,
Laszlo
 
Hi Laszlo,

As far as I know, TCP/IP uses big endian, data streams can use both and unicode usually little endian. However, big or little endian is related to the arrangement of bytes, not the bits inside the byte.

As for BitArray, index 0 is the least significant bit. Endian doesn't make any sense since the bits are stored in an array.

byte[] b = {7};
BitArray ba = new BitArray(b);

0000111;
6543210 // index positions


Happy coding!
Morten Wennevik [C# MVP]
 
Laszlo Szijarto said:
Thank you. Yes, it's EFFECTIVELY a Little Endian bit order.

But that's almost always the case. Last time this came up, someone
found some docs of (relatively obscure, IIRC) architectures which
labelled bits in a big endian order, but certainly common practice is
for them to be labelled in a little endian way.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top