PHP 8.0.0 Beta 4 available for testing

Predefined Constants

The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime.

GMP_ROUND_ZERO (integer)
GMP_ROUND_PLUSINF (integer)
GMP_ROUND_MINUSINF (integer)
GMP_MSW_FIRST (integer)
GMP_LSW_FIRST (integer)
GMP_LITTLE_ENDIAN (integer)
GMP_BIG_ENDIAN (integer)
GMP_NATIVE_ENDIAN (integer)
GMP_VERSION (string)
The GMP library version
add a note add a note

User Contributed Notes 2 notes

up
0
AnonyMouse At Do Not Mail Me Dot Com
1 month ago
Here is a table showing the output from gmp_export given gmp_init( 0x0123456789ABCDEF ) and various inputs parameters on a little endian 64-bit platform.
NOTE that the underscores in the table are used to illustrate the separation between "word"s (which are either char, short, int, or long).

+-----------+-----+--------+-------------------------+
| Word Size | Sig | Endian | gmp_export Hex Result   |
+-----------+-----+--------+-------------------------+
| 1 byte    | MSW | little | 01_23_45_67_89_AB_CD_EF |
+-----------+-----+--------+-------------------------+
| 1 byte    | MSW | big    | 01_23_45_67_89_AB_CD_EF |
+-----------+-----+--------+-------------------------+
| 1 byte    | LSW | little | EF_CD_AB_89_67_45_23_01 |
+-----------+-----+--------+-------------------------+
| 1 byte    | LSW | big    | EF_CD_AB_89_67_45_23_01 |
+-----------+-----+--------+-------------------------+
| 2 bytes   | MSW | little | 2301_6745_AB89_EFCD     |
+-----------+-----+--------+-------------------------+
| 2 bytes   | MSW | big    | 0123_4567_89AB_CDEF     |
+-----------+-----+--------+-------------------------+
| 2 bytes   | LSW | little | EFCD_AB89_6745_2301     |
+-----------+-----+--------+-------------------------+
| 2 bytes   | LSW | big    | CDEF_89AB_4567_0123     |
+-----------+-----+--------+-------------------------+
| 4 bytes   | MSW | little | 67452301_EFCDAB89       |
+-----------+-----+--------+-------------------------+
| 4 bytes   | MSW | big    | 01234567_89ABCDEF       |
+-----------+-----+--------+-------------------------+
| 4 bytes   | LSW | little | EFCDAB89_67452301       |
+-----------+-----+--------+-------------------------+
| 4 bytes   | LSW | big    | 89ABCDEF_01234567       |
+-----------+-----+--------+-------------------------+
| 8 bytes   | MSW | little | EFCDAB8967452301        |
+-----------+-----+--------+-------------------------+
| 8 bytes   | MSW | big    | 0123456789ABCDEF        |
+-----------+-----+--------+-------------------------+
| 8 bytes   | LSW | little | EFCDAB8967452301        |
+-----------+-----+--------+-------------------------+
| 8 bytes   | LSW | big    | 0123456789ABCDEF        |
+-----------+-----+--------+-------------------------+
See the full table at https://pastebin.com/2GX4L3dq

My conclusions and infrences:
* gmp_export appears to strips sign data as if calling gmp_abs( $gmp_resource )
* MSW might stand for Most Signifigant Word (order) as the most significant (highest digit) words come first.
    \- A "word" is a numeric type (char, short, int, or long) determined by the $word_size parameter
* LSW might stand for Least Signifigant Word (order) as the least significant (lowest digit) words come first.
* endianness only matters when you are using a word size greater than 1 because, with a word size of 1, each byte is copied over. With a word size of 2, each short is copied over. 4 is int. When copying numbers larger than a byte, endianness does matter because it changes the order of the bytes within the size of the unit. A 2-byte short will have its bytes swapped depending upon the endianness, but the bits in each byte will remain the same.

This note was too long to post, so I had to move the code to make the above table to https://pastebin.com/gWLU4GF8
up
0
i at tiankonguse dot com
7 years ago
when I var_dump these constants,these values is
GMP_ROUND_ZERO  0
GMP_ROUND_PLUSINF 1
GMP_ROUND_MINUSINF 2
GMP_VERSION  "5.0.2"
To Top