PHP | gmp_and() Function Last Updated : 15 Apr, 2018 Comments Improve Suggest changes Like Article Like Report 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. These parameters can be GMP objects 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 to numbers. Return Value: This function returns a GMP number which is bitwise AND of GMP numbers passed to it as parameters. Examples: Input : gmp_and("4", "2") Output : 0 Input : gmp_and("9", "10") Output : 8 Below programs illustrate the gmp_and() function in PHP: Program 1: Program to calculate the bitwise AND of GMP numbers when numeric strings as GMP numbers are passed as arguments. php <?php // PHP program to calculate the bitwise AND // GMP numbers passed as arguments // strings as GMP numbers $num1 = "10"; $num2 = "9"; // calculate the bitwise AND of $num1 and $num2 $res = gmp_and($num1, $num2); echo $res; ?> Output: 8 Program 2: Program to calculate the bitwise AND of GMP numbers when GMP numbers are passed as arguments. php <?php // PHP program to calculate the bitwise AND // GMP numbers passed as arguments // creating GMP numbers using gmp_init() $num1 = gmp_init(4); $num2 = gmp_init(2); //calculate the bitwise AND of $num1 and $num2 $res = gmp_and($num1, $num2); echo $res; ?> Output: 0 Reference: http://php.net/manual/en/function.gmp-and.php Comment More infoAdvertise with us Next Article PHP | gmp_and() Function A akash1295 Follow Improve Article Tags : Web Technologies PHP PHP-gmp Similar Reads PHP | gmp_div_r() Function The gmp_div_r() function is an in-built function in PHP which performs the division operation between two GMP numbers (GNU Multiple Precision : For large numbers) and returns the remainder. Syntax : gmp_div_r($num1, $num2) Parameters : This function accepts two GMP numbers, $num1 and $num2 as mandat 2 min read PHP | gmp_div_q() Function The gmp_div_q() is an inbuilt function in PHP which is used to perform division of GMP numbers(GNU Multiple Precision : For large numbers). Syntax: gmp_div_q($num1, $num2) Parameters: This function accepts GMP numbers, $num1 and $num2 as mandatory parameters as shown in the above syntax. These param 2 min read PHP | gmp_cmp() Function 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 2 min read 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_div_qr() Function The gmp_div_qr() function is an in-built function in PHP which performs the division operation between two GMP numbers (GNU Multiple Precision : For large numbers) and returns the quotient and remainder. Syntax : gmp_div_qr($num1, $num2) Parameters : This function accepts two GMP numbers, $num1 and 2 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 PHP | gmp_mul() Function The gmp_mul() function in PHP is an inbuilt function which is used to multiply two GMP numbers (GNU Multiple Precision: For large numbers). Syntax: GMP gmp_mul ( GMP $num1, GMP $num2 ) Parameters: This function accepts two GMP numbers. It is mandatory parameters as shown in the above syntax. These c 1 min read PHP | gmp_xor() Function The gmp_xor() is an in-built function in PHP which is used to calculate the XOR of 2 GMP numbers (GNU Multiple Precision : For large numbers). Syntax: gmp_xor( $num1, $num2 ) Parameters: This function accepts two GMP numbers $num1 and $num2 as mandatory parameters shown in the above syntax. These pa 2 min read PHP | gmp_gcd() Function The gmp_gcd() is an in built function in PHP which is used to calculate the GCD of 2 GMP numbers (GNU Multiple Precision : For large numbers). Syntax: gmp_gcd ( $num1, $num2 ) Parameters: This function accepts two GMP numbers $num1 and $num2 as parameters. This function calculates the GCD of these t 1 min read PHP | gmp_sub() Function The gmp_sub() is an in-built function in PHP which returns the subtraction of the two GMP numbers.(GNU Multiple Precision: For large numbers) Syntax: gmp_sub($num1, $num2) Parameters: This function accepts two GMP numbers $num1 and $num2 as mandatory parameters shown in the above syntax. These param 2 min read Like