• PHP Video Tutorials

PHP - gmp_mod() Function



Definition and Usage

The gmp_mod() function returns the modulus.

Description

The gmp_mod() function calculates the modulus of the given GMP numbers and the value returned is always positive GMP number .

Syntax

gmp_mod ( GMP $a , GMP $b) : GMP

Parameters

Sr.No Parameter & Description
1

a

It can a GMP resource number , a gmp object or a numeric string.

2

b

It can a GMP resource number , a gmp object or a numeric string. The value of b has to be positive and odd.

Return Values

PHP gmp_mod() function calculates modulus and returns it as a GMP number.

PHP Version

This function will work from PHP Version greater than 5.0.0.

Example 1

Working of gmp_mod −

<?php
   $mod = gmp_mod("11", "9");	
   echo "The modules of 11/9 is : ".$mod;
?>

This will produce following result −

The modules of 11/9 is : 2

Example 2

Working of gmp_mod −

<?php
   $mod = gmp_mod("0xFE", "0x80");	
   echo "The modules of 0xFE/0x80 is : ".$mod;
?>

This will produce following result −

The modules of 0xFE/0x80 is : 126
php_function_reference.htm
Advertisements