PHP | gmp_div_q() Function Last Updated : 30 May, 2022 Comments Improve Suggest changes Like Article Like Report 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 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 the quotient when $num1 is divided by $num2. The function returns positive, negative or zero depending upon the values of $num1 and $num2. Examples: Input : gmp_div_q("256", "16") Output : 16 Input : gmp_div_q("188", "4") Output : 47 Below programs illustrate the gmp_div_q() function in PHP: Program 1: Program to perform the division of GMP numbers when numeric strings as GMP numbers are passed as arguments. php <?php // PHP program to perform division of // GMP numbers passed as arguments // strings as GMP numbers $num1 = "-6"; $num2 = "2"; // calculates the quotient when // $num1 is divided by $num2 $quo = gmp_div_q($num1, $num2); echo $quo; ?> Output: -3 Program 2: Program to perform the division of GMP numbers when GMP numbers are passed as arguments. php <?php // PHP program to perform the division of // GMP numbers // creating GMP numbers using gmp_init() $num1 = gmp_init(289); $num2 = gmp_init(17); // calculates the quotient when // $num1 is divided by $num2 $quo = gmp_div_q($num1, $num2); echo $quo; ?> Output: 17 Program 3: Program to perform the division of GMP numbers when GMP numbers are passed as arguments. php <?php // PHP program to perform the division of // GMP numbers // creating GMP numbers using gmp_init() $num1 = gmp_init(3); $num2 = gmp_init(4); // calculates the quotient when // $num1 is divided by $num2 $quo = gmp_div_q($num1, $num2); echo $quo; ?> Output: 0 Reference: http://php.net/manual/en/function.gmp-div-q.php Comment More infoAdvertise with us Next Article PHP | gmp_div_q() Function A akash1295 Follow Improve Article Tags : Web Technologies PHP PHP-gmp Similar Reads 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_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_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_divexact() Function The gmp_divexact() is a built-in function in PHP which is used to check whether a GMP number(GNU Multiple Precision : For large numbers) is exactly divisible by another GMP number or not. If it so happens then function returns the exact result else any other irrelevant GMP number. Syntax: gmp_divexa 2 min read PHP | gmp_sqrt() Function The gmp_sqrt() is a built-in function in PHP which is used to calculate the square root of a GMP number (GNU Multiple Precision : For large numbers). This function returns only the integral part of the square root of the GMP number. Syntax: gmp_sqrt ( $num ) Parameters: This function accepts a GMP n 2 min read Like