none
Why does the BitArray use LittleEndian?

Answers

  • BitArray uses little-endian format because you are running your program on a little endian CPU. BitArray stores the bits in an internal array of integers. So if the integers on your platform are little endian, your BitArray will be little endian too. If you look at the internal implementation of the constructor BitArray.BitArray(byte[]) (using a tool like Lutz Roeder's Reflector), you will notice that the bytes are placed into the integers using bitshifting and masking. So if you execute your code on a big endian CPU, your integers and hence your BitArrays will be big endian.
    Tuesday, April 12, 2005 10:14 PM
    Moderator

All replies

  • BitArray uses little-endian format because you are running your program on a little endian CPU. BitArray stores the bits in an internal array of integers. So if the integers on your platform are little endian, your BitArray will be little endian too. If you look at the internal implementation of the constructor BitArray.BitArray(byte[]) (using a tool like Lutz Roeder's Reflector), you will notice that the bytes are placed into the integers using bitshifting and masking. So if you execute your code on a big endian CPU, your integers and hence your BitArrays will be big endian.
    Tuesday, April 12, 2005 10:14 PM
    Moderator
  • I think James knows much more about .Net than I do but the x86 architecture uses little-endian and I assume that BitArray is just maintaining the format of the bits as they exist in memory. Do you understand why the x86 architecture uses little-endian?


    Sam Hobbs
    SimpleSamples.Info

    Tuesday, January 01, 2013 11:41 PM