Re: [PHP-DEV] pack() and unpack() 64 bit format codes

[email protected] (Andrea Faulds)
Newsgroups php.internals
Message-ID <[email protected]>
On 9 Sep 2014, at 19:36, Leigh <[email protected]> wrote:

> Hi Internals,
> 
> I would like to propose giving pack() and unpack() 64 bit format
> codes, mimicking the current behaviour of 32 bit format codes.

What would this do on 32-bit platforms?

> Pack and unpack are obviously functions inspired by Perl, which has
> the 64 bit format codes 'q' and 'Q'. So the first half of my proposal
> is to give pack() and unpack() these options.
> 
> q - signed long long (always 64 bit, machine byte order)
> Q - unsigned long long (always 64 bit, machine byte order)
> 
> Perl does not have format codes to specify endianness, so the second
> half of my proposal is to introduce two more format codes for PHP that
> behave differently from Perl.
> 
> J - unsigned long long (always 64 bit, big endian byte order)
> P - unsigned long long (always 64 bit, little endian byte order)
> 
> I have chosen these letters _because_ they already exist in Perl,
> however their function does not suit PHP. J is for Perl internal
> integers, and P is for a pointer to a structure. Both of these are
> things that make no sense to support in PHP.

Why is there no big/little-endian signed long long?

--
Andrea Faulds
http://ajf.me/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.