【问题标题】:php, how to pack int to signed 64bit little-endian string?php,如何将 int 打包为签名的 64 位 little-endian 字符串?
【发布时间】:2021-02-03 18:38:59
【问题描述】:

奇怪的是 pack() 不支持 *signed* 64bit little-endian,而它支持 unsigned,那么我该如何打包一个有符号的呢?

作为参考,如果我想要一个无符号的 64 位 little-endian pack(),我会这样做

    $packed = pack("P", $i);

【问题讨论】:

    标签: php integer endianness pack


    【解决方案1】:

    来自php官方文档pack

    请注意,仅区分有符号和无符号值 影响函数 unpack(),其中函数 pack() 给出相同的 有符号和无符号格式代码的结果。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-10
      • 2019-03-13
      • 1970-01-01
      相关资源
      最近更新 更多