Re: signed int64 pack/unpack [message #184615 is a reply to message #184593] |
Sun, 12 January 2014 23:27 |
Ben Bacarisse
Messages: 82 Registered: November 2013
Karma:
|
Member |
|
|
cameron7(at)gmail(dot)com writes:
> I guess I'll reply with my own solution. Turns out there are 2
> separate issues here.
Here's mine. You might have to alter the order of the two 32-bit
components to match your external format. I've used the same names you
might be able to drop it into your tests.
echo "PACKING: ".$i64.PHP_EOL;
$ps = pack('N2', $i64 >> 32, $i64 & 0xffffffff);
list(, $hi, $lo) = unpack('N2', $ps);
$unpack = ($hi << 32) + $lo;
echo "UNPACKED: ".$unpack.PHP_EOL;
--
Ben.
|
|
|