Javatpoint Logo
Javatpoint Logo

PHP gmp_mod() Function

The modulus is given as an output by the GMP gmp_mod() function. This function calculates the modulo of two GMP numbers. Modulo is an operation in math that finds the number left over after dividing one integer by another. It is often written as a mod or shown by the percentage (%) symbol.

Syntax

The following syntax shows the gmp_mod() function and its operation.

Parameters

  • The above syntax shows that the function must take two GMP numeric values as mandatory parameters: $number and $mod.
  • In PHP version 5.6, these parameters can be a GMP object.
  • We can also pass numerous numeric strings, as long as necessary, to turn the string into a number.

Return Value

The function gives back a GMP number, which is same as modulo ($number % $d).

Examples

The following examples show modulo operation using a function with various parameters.

Example1: the given an example uses the gmp_mod() with the essential and positive values.

Output:

The image shows the "Modulo value" of the given two values.

PHP gmp_mod() function

Example2: the given example uses the gmp_mod() with the positive and negative values.

Output:

The image shows the "Modulo value" of the given two values.

PHP gmp_mod() function

Example3: the given example uses the gmp_mod() with the variable values.

Output:

The image shows the "Modulo value" of the given value.

PHP gmp_mod() function

Example4: the following example shows the gmp_mod() function with the GMP parameter and its value. We can use absolute, init, and other GMP functions data.

Output:

The image shows the "Modulo value" of the given two values.

PHP gmp_mod() function

Conclusion

The gmp_mod() function gives modulo of the value without mathematical operation. It is used for mathematical functions without lengthy and complicated processes.







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA