Reputation: 3341
I need to convert big-endian, 8-bytes, uint64
into an integer.
I can only find Q
in the documentation for 64-bit unsigned, native endian (uint64_t)
and nothing for 64-bit big-endian uint64
.
So I just want to make sure that Q
is the right one to use since Q does not specify that it is for big-endian
What I'm using: uid = io.read(8).unpack("Q")[0]
Or should I break it down into 2 32-bit integers then convert to string then concatenate like ...
uid = (io.read(4).unpack("N")[0].to_s + io.read(4).unpack("N")[0].to_s).to_i
Upvotes: 3
Views: 1823
Reputation: 198324
From the same documentation page you linked:
S> L> Q> | Integer | same as the directives without ">" except s> l> q> | | big endian
Upvotes: 3