The order of the bits matters when the field uses a part of the byte or spans bytes beginning or ending (or both) part of the path through the byte.
Example: 2 bytes of data, first 235 (decimal), second 173 (decimal), as well as hexadecimal EB and AD.
I want the bit to start with the fourth bit through the 12th bit. So, skip over 3 bits, make a 9-bit unsigned integer from the next 9 bits.
I argue that there are 4 possible outcomes:
byteOrder, bitOrder
* bigEndian, bigEndian results in hex 0BA or decimal 186
* littleEndian, littleEndian results in hex 1BD or decimal 445
* littleEndian, bigEndian results in hex 05D or decimal 93
* bigEndian, littleEndian results in hex 1DE or decimal 478
I saw the first 3 of these 4 in the data. big, big and small, little can be done.
Hint for solving this problem.
If the byte order is large endian, write the bytes from top left to right. If the byte order is slightly narrowed, write the bytes on the right, increasing to the left.
Mike beckerle
source share