Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

php
communitycreator

What is bcpowmod in PHP?

Sheza Naveed

bcpowmod(): is a PHP function that raises an arbitrary precision number to another, reduced by a specified modulus.

Syntax


bcpowmod(
    string $num,
    string $exponent,
    string $modulus,
    int $scale = null
): string

Parameters

  • num: It is the base number. num is of the string type.

  • exp: It is the exponent. exp is of the integral string type.

  • modulus: It is the modulus. modulus is of the integral string type.

  • scale: variable of the int type. It is an optional parameter.

    scale sets the number of digits after the decimal place in the result. The default value of scale is 0.

Return value

The function returns the result as a string.

The function returns false if the exponent is negative or the modulus is zero.

Code

<?php
$result = bcpowmod("2", "3", "3");
echo $result;

// scale = 4
$result = bcpowmod("2", "3", "3", 4);
echo $result;
?>

Output


2
2.0000

RELATED TAGS

php
communitycreator
RELATED COURSES

View all Courses

Keep Exploring