note 125197 added to gmp.constants

From: Date: Mon, 20 Jul 2020 16:21:53 +0000
Subject: note 125197 added to gmp.constants
Groups: php.notes 
Request: Send a blank email to php-notes+get-214879@lists.php.net to get a copy of this message
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 ---- Server IP: 45.112.84.4 Probable Submitter: 103.51.166.36 (proxied: 2605:a000:1613:c070:8ea1:d1ad:da6c:69fe) ---- Manual Page -- http://php.net/manual/en/gmp.constants.php Edit -- https://master.php.net/note/edit/125197 Del: integrated -- https://master.php.net/note/delete/125197/integrated Del: useless -- https://master.php.net/note/delete/125197/useless Del: bad code -- https://master.php.net/note/delete/125197/bad+code Del: spam -- https://master.php.net/note/delete/125197/spam Del: non-english -- https://master.php.net/note/delete/125197/non-english Del: in docs -- https://master.php.net/note/delete/125197/in+docs Del: other reasons-- https://master.php.net/note/delete/125197 Reject -- https://master.php.net/note/reject/125197 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#214879) next »