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.
Parameters : This function accepts two 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 numeric strings can be passed to the function provided that it is possible to convert those strings to numbers.
Return Value : This function returns an array with two components :
- First being the quotient of the division.
- Second being the remainder of the division.
Input : $num1 = 146, $num2 = 12 Output : Quotient = 12, Remainder = 2 Array (  => GMP Object ( [num] => 12 )  => GMP Object ( [num] => 2 ) ) Input : $num1 = 189126457831, $num2 = 12098123409 Output : Quotient = 15, Remainder = 7654606696 Array (  => GMP Object ( [num] => 15)  => GMP Object ( [num] => 7654606696 ) )
Below programs will illustrate the use of gmp_div_qr() function.
Program 1 : Program to perform the division of GMP numbers when GMP numbers are passed as arguments.
Array (  => GMP Object ( [num] => 15 )  => GMP Object ( [num] => 2 ) )
Program 2 : Program to perform the division of GMP numbers when numeric strings as GMP numbers are passed as arguments.
Array (  => GMP Object ( [num] => 68152 )  => GMP Object ( [num] => 13295953 ) )
Reference : http://php.net/manual/en/function.gmp-div-qr.php
- p5.js | hex() function
- PHP | pi( ) Function
- D3.js | d3.max() function
- p5.js | str() function
- PHP | Ds\Map map() Function
- PHP | Ds\Map last() Function
- p5.js | box() Function
- p5.js | arc() Function
- PHP | pow( ) Function
- PHP | Ds\Set last() Function
- PHP | Ds\Set first() Function
- p5.js | sin() function
- PHP | Ds\Set add() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.