FAQ
Hi,

I'm writing to request for RFC karma.

Here is what I am doing and why doing this.

The pack/unpack's parameter 'd' and 'f' are machine order in PHP.

The number 236.0 packed to 'd' is: 0000000000806d40.

I was reversing a game save file, which uses 406D800000000000.
Here is how I decode that in PHP.

         public function readDouble()
         {
                 $data = substr($this->stream, $this->ptr, 8);
                 $this->ptr += 8;

                 $data = implode('', array_reverse(str_split($data, 1)));

                 $int = unpack('d', $data);
                 return (double) ($int[1]);
         }

Since integers are allowed to pack/unpack in both little endian and
big endian, I think double/float also need.

In this PR, I choose:
e: little endian double
E: big endian double
g: little endian float
G: big endian float.

BTW, these formats, 'e', 'E', 'g', and 'G' are not taken in Perl.


I've created a PR: https://github.com/php/php-src/pull/1905



sskaje
sskaje@gmail.com
https://sskaje.me/

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupphp-internals @
categoriesphp
postedMay 12, '16 at 1:32p
activeMay 12, '16 at 1:32p
posts1
users1
websitephp.net

1 user in discussion

Sskaje: 1 post

People

Translate

site design / logo © 2018 Grokbase