Re: signed int64 pack/unpack [message #184581 is a reply to message #184580] |
Sun, 12 January 2014 02:59 |
The Natural Philosoph
Messages: 993 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 12/01/14 02:46, cameron7(at)gmail(dot)com wrote:
> Hi, yes, sorry I am running 64-bit OS and 64-bit PHP. PHP_INT_MAX is
> giving appropriate value.
>
> Specifics from `php -i`: PHP Version => 5.4.6-1ubuntu1.5
>
> The code has become extremely ugly, and still not working perfectly,
> thus the reason for trying to find others who may have experience
> with this. The pack / unpack functions don't provide support for
> 64-bit integers directly so I'm looking for at least a sound "hack".
>
> I've tried all sorts of things, from base_convert to simply trying to
> extract and iterate over a bitwise comparison against each bit in 4
> separate 16-bit ints, but nothing I've tried so far is working
> correctly.
>
> Basically, the context for this is I'm writing a client for a custom
> protocol in which several of the components of that protocol in
> requests and responses require big endian 64-bit signed int, thus the
> reason for the need to pack / unpack.
>
I have to say this is where I would probably be trying to write a C
library and wrap it in PHP..
Or write a C daemon and interrogate that..via a named pipe or system
type call.
This is system level programming and PHP is simply not the right tool
for it.
--
Ineptocracy
(in-ep-toc’-ra-cy) – a system of government where the least capable to
lead are elected by the least capable of producing, and where the
members of society least likely to sustain themselves or succeed, are
rewarded with goods and services paid for by the confiscated wealth of a
diminishing number of producers.
|
|
|