- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这段代码:
import Data.Binary
import qualified Data.ByteString.Internal as BS (c2w, w2c)
import qualified Data.ByteString.Lazy as B
import Data.Int
main :: IO ()
main = do
B.putStr $ encode $ (0x01020304 :: Int32)
在我的机器上产生这个输出(通过 xxd 运行):
00000000: 0102 0304 ....
这告诉我它是按大端顺序输出的,但是我有一个 x86_64 系统,所以...这是怎么回事?
最佳答案
Data.Binary
模块在 documentation 中指定:
Values encoded using the
Binary
class are always encoded in network order (big endian) form, and encoded data should be portable across machine endianness, word size, or compiler version. For example, data encoded using the Binary class could be written on any machine, and read back on any another.
因此它不适用于机器的 then endianess,但始终使用 big endian,这样将对象编码为 ByteString
,也可以用另一台机器解码。
关于haskell - 为什么我的 ByteString 在我的 x86_64 架构上是 BigEndian 格式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69608195/
默认情况下,BinaryWriter 类写入 int 值,低位在左侧(例如,在十六进制编辑器中查看结果文件时,(int)6 变为 06 00 00 00)。我需要右边的低位(例如 00 00 00 0
我需要通过网络获取一个整数。这是转换为大端字节的正确方法吗? pack("I",socket.htonl(integer_value)) 我将其解压为: socket.ntohl(unpack("I"
有人能告诉我为什么大端/小端会影响音频信号的波形表示吗? 最佳答案 比喻: 如果互联网上的陌生人给你日期“10/11”,那么你不能确定他们是指 11 月 10 日还是 10 月 11 日,所以你需要知
我考虑从库中丢弃处理大端情况的代码,如果平台不是小端,则在初始化期间简单地抛出一个异常。如果我们限制为,我无法想象会有任何大端硬件 托管任何网站的典型服务器硬件 服务器根据开放计算项目规范 所有常见的
这个问题在这里已经有了答案: How do I convert between big-endian and little-endian values in C++? (35 个答案) 关闭 6 年
当我尝试在文件中写入具有如下值的二进制文件时: public static main(String[] args){ ByteBuffer output = ByteBuffer.alloca
我正在处理为 ipv4 编写的遗留代码。现在我已经为 ipv6 添加了类似的代码。我已经在主机上进行了尝试和测试..但我担心它是否会在 powerpc 上工作,因为字节序...代码是从传入流中提取 i
请原谅我用词不当,但我找不到更好的解释方式。 据我了解,C# 是一种 WORA 语言 - 您可以在一台机器上编写它并在另一台机器上部署它,因为 MSIL 直到应用程序实际运行时才会编译。 那么为什么
之前我提出了一个关于将 byte[] 转换为 short[] 的问题,我遇到的一个新问题是转换/不转换来自 byte 的数据[] 到 BigEndian。 这是正在发生的事情: 我正在使用 Targe
我想要一个带有字符串参数的 lua 函数。字符串有 N+2 字节的数据。前两个字节具有 bigendian 格式的长度,其余 N 个字节包含数据。 Say data is "abcd" So the
我想要一个带有字符串参数的 lua 函数。字符串有 N+2 字节的数据。前两个字节具有 bigendian 格式的长度,其余 N 个字节包含数据。 Say data is "abcd" So the
我有: Float(bitPattern: UInt32(bigEndian: data.withUnsafeBytes { $0.pointee } )) 这段代码正在将数据转换为 float ,但
这段代码: import Data.Binary import qualified Data.ByteString.Internal as BS (c2w, w2c) import qualified
我有一个 BigEndian 格式的 QbyteArray 变量我想用最少的过程从该变量中获取一个 float 组。最快的方法是什么? 现在我正在使用以下代码,但效率不高,我认为应该有更好的方法吗?
我正在使用 Kryo 反序列化最初在 Spark 中序列化的类。 Kryo 以 BigEndian 格式编写其所有原语,但是当我尝试在另一台计算机上反序列化这些值时,该值将像 LittleEndian
我有一台在 power-pc-7 bigendian 64 位上运行的 AIX 机器,我知道在 Windows、Linux 和 Mac 上安装 Go 编译器很容易,但如果我们想在 AIX 上安装它,那
我正在尝试将通过蓝牙连接获得的 NSData 类型的 6 字节十六进制转换为适当的整数值。我知道这是 Big Endian 类型,我需要转换为 little Endian。然而,每次我尝试转换它时,我
我是一名优秀的程序员,十分优秀!