PHP | bcmod() Function
The bcmod() function in PHP is an inbuilt function and is used to calculate modulus of an arbitrary precision numbers. This function accepts an arbitrary precision number and returns the modulus of that number after scaling the result to a specified precision.
Syntax:
string bcadd ( $dividend, $modulus)
Parameters: This function accepts two parameters as shown in the above syntax and explained below:
- $dividend: This parameter is of string type and represents the dividend which will be divided by the given modulus value $modulus. This parameter is mandatory.
- $modulus: This parameter is of string type and represents the modulus. This parameter is mandatory.
Return Value: This function returns the remainder when $dividend is divided by $modulus. In other words, it returns the value equivalent to ($dividend % $modulus). If $modulus is zero, then this function returns NULL.
Examples:
Input: $dividend = 11, $modulus = 3 Output: 2 Input: $dividend = 3, $modulus = 11 Output: 3
Below programs illustrate the bcmod() function in PHP :
Program 1:
<?php // PHP program to illustrate bcmod() function // input numbers with arbitrary precision $dividend = "11"; $modulus = "3"; // calculates the modulus $res = bcmod($dividend, $modulus); echo $res; ?> |
Output:
2
Program 2:
<?php // PHP program to illustrate bcmod() function // input numbers with arbitrary precision $dividend = "3"; $modulus = "11"; // calculates the modulus $res = bcmod($dividend, $modulus); echo $res; ?> |
Output:
3
Reference:
http://php.net/manual/en/function.bcmod.php
Recommended Posts:
- How to call a function that return another function in JavaScript ?
- How to get the function name from within that function using JavaScript ?
- How to get the function name inside a function in PHP ?
- PHP | Ds\Map get() Function
- CSS | rgb() Function
- p5.js | box() Function
- D3.js | d3.map.set() Function
- PHP | exp() Function
- D3.js | d3.min() function
- PHP | min( ) Function
- PHP | max( ) Function
- D3.js | d3.rgb() Function
- p5.js | int() function
- D3.js | d3.hcl() Function
- PHP | dir() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



