简体   繁体   中英

Bits stream reading order

I've read in manual:

For bit-oriented delivery, the bit order for the byte stream format is specified to start with the MSB of the first byte, proceed to the LSB of the first byte, followed by the MSB of the second byte, etc.

In my application I have to cope with bits. (for example I have decimal number 5, in binary format it looks like 00000101) So, is that means (according to manual) that order of bits I read is

<= 0 <= 0 <= 0 <= 0 <= 0 <= 1 <= 0 <= 1 (first read bit I read is 0, second is 0 etc....)

or it means such order of reading bits:

<= 1 <= 0 <= 1 <= 0 <= 0 <= 0 <= 0 <= 0 (first read bit I read is 1, second is 0 etc....)

Thanks

  • MSB: Most significant bit
  • LSB: Least significant bit

So for 5 (0000_0101) the bit on the left (representing 2 7 ) is "most significant" and the bit on the right (representing 2 0 ) is the "least significant". Therefore, yes, expect 0 to be the first bit.

在Java中,用于读取和写入字节流的默认方法将自动默认为网络字节顺序,因此您可能会很高兴。

如果流中的第一个字节是0x7D,0x01 ,则位流从0,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1开始。

Byte order is mostly referred to as endian-ness. You have big-endian systems and little-endian systems.

Big endian you have the Most Significant Bit first and in Little Endian, the least significant bit is first.

Most network traffic is big endian. A X86 machine is always little-endian.

Here is more info about endian-ness

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM