Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

php
communitycreator

What is bcmod in PHP?

Sheza Naveed

bcmod is a function in PHP that finds the modulus of the arbitrary precision number.

Syntax

bcmod(string $num1, string $num2, int $scale = null): string

Parameters

  • num1 - variable of type int.

num1 is a dividend.

  • num2 - variable of type int.

num2 is a divisor.

  • scale - variable of type int. This is an optional parameter. scale is used to set the number of digits after the decimal place in the result. The default value of scale is 0.

Return value

The function returns the modulus. The value returned is of type string.

null is returned if num2 is zero.

Return value has the same sign as that of num1.

Code

<?php
$num1 = '5';
$num2 = '3';

echo bcmod($num1, $num2);
?>

Output

2

RELATED TAGS

php
communitycreator
RELATED COURSES

View all Courses

Keep Exploring