
PHP gmp_mod() Function
As of my last update in September 2021, the gmp_mod()
function is available in PHP’s GMP (GNU Multiple Precision) extension. The gmp_mod()
function is used to calculate the remainder of the division of one GMP number by another GMP number.
Here’s the syntax of the gmp_mod()
function:
GMP gmp_mod ( GMP $num , GMP $mod )
Parameters:
$num
: The GMP number to be divided.$mod
: The GMP number representing the divisor.
Return value:
- The
gmp_mod()
function returns a GMP number representing the remainder of the division of$num
by$mod
.
Example:
$a = gmp_init('15');
$b = gmp_init('4');
$remainder = gmp_mod($a, $b);
echo "The remainder of 15 divided by 4 is: " . gmp_strval($remainder); // Output: 3
In this example, the gmp_mod()
function is used to calculate the remainder when the GMP number 15
is divided by the GMP number 4
. The result is 3
.
The gmp_mod()
function is useful for performing modulo arithmetic with large integers, and it can be used in various mathematical calculations and cryptographic algorithms.
Please note that the GMP extension needs to be enabled in your PHP configuration to use this function. Additionally, the availability of functions may change in newer PHP versions, so always refer to the PHP manual for the specific version you are using.