PHP - gmp_sqrtrem() Function
Definition and Usage
The gmp_sqrtrem() function calculates the square root with remainder.
Description
The gmp_sqrtrem() calculates square root for the given GMP number and returns the remainder.
Syntax
gmp_sqrtrem ( GMP $a ) : array
Parameters
| Sr.No | Parameter & Description |
|---|---|
| 1 |
a It can a GMP resource number , a gmp object or a numeric string. |
Return Values
PHP gmp_sqrtrem() function returns an array with the first value with square root and second value as the remainder.
PHP Version
This function will work from PHP Version greater than 5.0.0.
Example 1
Working of gmp_sqrtrem() −
<?php
$num = gmp_sqrtrem('150');
echo "The square root value is : ".$num[0]." and remainder is : ".$num[1];
?>
This will produce following result −
The square root value is : 12 and remainder is : 6
Example 2
Working of gmp_sqrtrem() −
<?php
$num = gmp_rootrem('2685', 3);
echo "The square root value is : ".$num[0]." and remainder is : ".$num[1];
?>
This will produce following result −
The square root value is : 13 and remainder is : 488
php_function_reference.htm
Advertisements