ruby unpack为64位整数

时间:2017-03-23 23:05:28

标签: ruby binary

我需要将big-endian, 8-bytes, uint64转换为整数。

我只能在Q 64-bit unsigned, native endian (uint64_t)中找到64-bit big-endian uint64Q找不到big-endian

所以我只想确保uid = io.read(8).unpack("Q")[0]是正确的,因为Q没有指明它是uid = (io.read(4).unpack("N")[0].to_s + io.read(4).unpack("N")[0].to_s).to_i

我正在使用的内容:alert_dns.format(i)

或者我应该将其分解为2个32位整数然后转换为字符串然后连接如...

alert_dns.format(insert=i)

1 个答案:

答案 0 :(得分:0)

在您链接的同一文档页面中:

S> L> Q>  | Integer | same as the directives without ">" except
s> l> q>  |         | big endian
相关问题