From: "Jason Voegele" <jason / jvoegele.com>
>
> For a Ruby program I'm writing, I'm receiving binary data over a 
> network.  For most of the data I need to read, String#unpack works like 
> a charm.  However, some of the data I receive is 64 bit 2s complement 
> integers, and since String#unpack does not have a mode for 64 bit 
> numbers I'm having trouble figuring out how to get a Bignum from the 
> binary data.
> 
> As I've mentioned, the data is in 2s complement representation[1] such 
> that 1 is encoded as "\001\000\000\000\000\000\000\000" and -1 is 
> encoded as "\377\377\377\377\377\377\377\377" (those are both little 
> endian, by the way).

How about unpacking the string as: nn = str.unpack("lL"),
(or whichever endian-format is appropriate for your situation),
then combining the halves as: n = (nn[0] << 32) | nn[1]


HTH,

Bill