Bit Order and Byte Order in a Packed Stream
Byte order describes the order of multiple byte units. Bit packing also chooses which position inside each byte is filled first.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace three bits
Under a most-significant-first convention, bits 1, 0, 1 can fill the top three positions as 10100000 when padded with zeros. A least-significant-first layout gives another stored byte. See fixed-width binary notation.
Test an asymmetric sequence
An all-zero sample cannot reveal a reversed packing rule. Check one independently specified byte pattern in a round-trip compatibility test.[1][2]
Trace the same bits with opposite packing orders
If the first three bits are one, zero, one and the rest pad with zeros, most-significant-first packing yields 10100000, or hex A0. Least-significant-first packing yields 00000101, or hex 05. See hexadecimal bytes.
Stream prefix: 1,0,1
Fill positions 7,6,5 → A0
Fill positions 0,1,2 → 05
The announced stream length remains 3
Test across a full byte boundary
Byte order describes how several bytes represent larger values. Bit order here describes placement of successive stream bits within one byte. Use a non-symmetric sequence spanning two bytes to test both.