java - 比特流读取顺序

标签 java java-io

我读过手册:

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.

在我的应用程序中,我必须处理位。 (例如我有十进制数 5,二进制格式看起来像 00000101) 那么,这是否意味着(根据手册)我读取的位顺序是

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

或者它意味着读取位的顺序:

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

谢谢

最佳答案

  • MSB:最高有效位
  • LSB:最低有效位

因此,对于 5 (0000_0101),左侧的位(代表 27)是“最高有效位”,右侧的位(代表 20)是“最不重要”。因此,是的,第一位应该是 0。

关于java - 比特流读取顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5595057/

相关文章:

java - 修改库中日志消息的级别

java - 从java中的二进制数据创建pdf

java.io.File.<init>(File,String) JDK 版本依赖

java - 字符流和字节流之间缺乏一对一的关系

java - 从目录读取所有文件和嵌套文件时线程 "main"java.lang.StackOverflowError 中出现异常

Java String.split() 失控

Java ActionListener(多个语句)

java - 如何修复此运行时错误 : java. lang.IndexOutOfBoundsException

Java:如何在 CameraX previewView 上绘图?

java - FilterOutpuStream是否正常写入?