PHP | gmp_cmp() Function Last Updated : 14 Apr, 2018 Comments Improve Suggest changes Like Article Like Report The gmp_cmp() is an inbuilt function in PHP which is used to compare two GMP numbers(GNU Multiple Precision : For large numbers). Syntax: gmp_cmp($num1, $num2) Parameters: This function accepts two GMP numbers $num1 and $num2 as mandatory parameters as shown in the above syntax for comparing. These parameters can be a GMP object in PHP version 5.6 and later, or we are also allowed to pass numeric strings such that it is possible to convert those strings in numbers. Return Value: The function returns "1" if $num1 > $num2, "0" if $num1 equal to $num2, "-1" if $num1 < $num2. Examples: Input : gmp_cmp("1234", "1236") Output : -1 Input : gmp_cmp("3569", "3569") Output : 0 Below programs illustrate the gmp_cmp() function in PHP: Program 1: Program to compare the two GMP numbers when they are passed as numeric strings. php <?php // PHP program to compare two // GMP numbers passed as arguments // strings as GMP numbers $num1 = "12356"; $num2 = "12356"; // compares the two numbers and // gives the result "0" as both are equal $res = gmp_cmp($num1, $num2); echo $res; ?> Output: 0 Program 2: Program to compare two GMP numbers when they are passed as GMP numbers as arguments. php <?php // PHP program to compare two // GMP numbers passed as arguments // creating GMP numbers using gmp_init() $num1 = gmp_init(12355); $num2 = gmp_init(12356); // compares these two numbers and // gives the result "-1" as $num1 < $num2 $res = gmp_cmp($num1, $num2); echo $res; ?> Output: -1 Reference: http://php.net/manual/en/function.gmp-cmp.php Comment More infoAdvertise with us Next Article PHP | gmp_cmp() Function A akash1295 Follow Improve Article Tags : Web Technologies PHP PHP-gmp Similar Reads PHP | gmp_com() Function The gmp_com() is an inbuilt function in PHP which is used to calculate the one's complement of a GMP number(GNU Multiple Precision : For large numbers). Syntax: gmp_com($num) Parameters: This function accepts a GMP number $num as a mandatory parameter as shown in the above syntax. This parameter can 2 min read PHP | gmp_and() Function The gmp_and() is an inbuilt function in PHP which is used to calculate the bitwise AND of two GMP numbers(GNU Multiple Precision : For large numbers). Syntax: gmp_and($num1, $num2) Parameters: This function accepts two GMP numbers, $num1, $num2 as mandatory parameters as shown in the above syntax. T 2 min read PHP | gmp_clrbit() Function The gmp_clrbit() function is an in-built function in PHP which clears a bit of a GMP number (GNU Multiple Precision). The gmp_clrbit() function sets the bit at a specified index in a GMP number to 0. The index starts at zero from the least significant bit. Syntax : gmp_clrbit( $num, $index ) Paramet 2 min read PHP | gmp_export() function The gmp_export() function is an inbuilt function in PHP which exports a GMP number(GNU Multiple Precision: For Large Numbers) to a binary string. Syntax:Â string gmp_export ( GMP $gmpnumber, int $word_size, int $options ) Parameters: The gmp_export() function accepts three parameters as shown above 1 min read PHP | gmp_or() Function The gmp_or() is an inbuilt function in PHP which is used to calculate the bitwise OR of two GMP numbers(GNU Multiple Precision : For large numbers). Syntax: gmp_or($num1, $num2) Parameters: This function accepts two GMP numbers, $num1, $num2 as mandatory parameters as shown in the above syntax. Thes 2 min read Like