From: David Balmain Date: 2006-09-23T00:09:17+09:00 Subject: Re: 64-bit integers in network byte-order On 9/22/06, Francis Cianfrocca wrote: > All, > does Ruby have a way to convert 64-bit integers to and from network > order in a platform-independent way? > > For 32-bit ints, I can use [value].pack("N"). The conversion operator > for 64-bit ints ("Q") doesn't have a network-order variant. (I assume > this is because the underlying byte-order converters (htons/htonl) don't > have a 64-bit version on 32-bit platforms.) > > -- > Posted via http://www.ruby-forum.com/. > Hi Francis, A quick scan of the Ruby source tells me that you'll have to implement it yourself. Network byte order is big-endian so you should be able to do it like this: [val >> 32, val & 0xFFFFFFFF].pack("NN") At least I think that is correct. Cheers, Dave