PHP | gmp_sqrtrem() Function Last Updated : 14 Apr, 2018 Comments Improve Suggest changes Like Article Like Report The gmp_sqrtrem() 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) with remainder. This function also returns only the integral part in the square root of the GMP number as the gmp_sqrt() function. The remainder is basically the difference between the GMP number and the square of the square root value as returned by this function. Syntax: gmp_sqrtrem ( $num ) Parameters: This function accepts a GMP number $num as a mandatory parameter as shown in the above syntax whose square root we want to calculate. This parameter can be a GMP object in PHP version 5.6 and later, or we are also allowed to pass a numeric string provided that it is possible to convert that string to a number. Return Value: This function returns an array of two GMP numbers. The first element in this array is the integral part in the square root of the GMP number passed to the function as parameter and the second element is the remainder. The remainder is calculated as the difference between the GMP number and the square of first element of this array. Examples: Input : "9" Output : 3 Input : "24" Output : 4 Below programs illustrate the gmp_sqrtrem() function in PHP : Program 1: Program to calculate the square root with remainder of a GMP number when numeric strings as GMP numbers are passed as arguments. php <?php // PHP program to calculate the square root // of a GMP number // passing numeric strings as GMP numbers $num = gmp_init("24"); // calculates the square root of a GMP number // with remainder list($squareRoot, $rem) = gmp_sqrtrem($num); echo $squareRoot." ".$rem; ?> Output: 4 8 Program 2: Program to calculate the square root with remainder of a GMP number when GMP numbers are passed as arguments. php <?php // PHP program to calculate the square root // of a GMP number // creating GMP numbers using gmp_init() $num = gmp_init(24, 10); // calculates the square root of a GMP number // with remainder list($squareRoot, $rem) = gmp_sqrtrem($num); echo $squareRoot." ".$rem; ?> Output: 4 8 Reference: http://php.net/manual/en/function.gmp-sqrtrem.php Comment More infoAdvertise with us Next Article PHP | gmp_sqrtrem() Function B barykrg Follow Improve Article Tags : Web Technologies PHP PHP-gmp Similar Reads 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 PHP | gmp_rootrem() Function The gmp_rootrem() is a built-in function in PHP which is used to calculate the nth root of a GMP number (GNU Multiple Precision : For large numbers) and returns the integer component of the nth root and its remainder . Syntax : gmp_rootrem($num,$n) Parameters : This function accepts two mandatory pa 2 min read PHP | gmp_strval() Function The gmp_strval() is an inbuilt function in PHP which returns the string value of a GMP number. (GNU Multiple Precision: For large numbers). Syntax: string gmp_strval ( GMP $num, int $base ) Parameters: The function accepts two parameters $num and $base as shown above and described below. $num - The 3 min read PHP | gmp_root() Function The gmp_root() is an in-built function in PHP which returns the integer part of the N-th root of a GMP number(GNU Multiple Precision: For large numbers).Syntax:  gmp_root( $num, $n ) Parameters: The function accepts two mandatory parameters $num and $n.  $num - This is the GMP number whose integer 2 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