HomeMenu
Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

bcpow

Description

The bcpow of BCMath for PHP raises an arbitrary precision number to another.

Syntax

bcpow(
    string $num,
    string $exponent,
    ?int $scale = null
): string

Parameters

num

The base, as a string.

exponent

The exponent, as a string.

If the exponent is non-integral, it is truncated. The valid range of the exponent is platform specific, but is at least -2147483648 to 2147483647.

scale

Sets the number of digits after the decimal place in the result.

If omitted, it will default to the scale set globally with the bcscale() function, or fallback to 0 if this has not been set.

Return

Returns the result as a string.

Examples

1 · num exponent

<?

$num = '2';
$exponent = '3';

$return = bcpow($num, $exponent);

echo $return;
8

2 · scale

<?

$num = '2';
$exponent = '3';
$scale = 6;

$return = bcpow($num, $exponent, $scale);

echo $return;
8.000000

3 · bcscale

<?

$scale = 6;

bcscale($scale);

$num = '2';
$exponent = '3';

$return = bcpow($num, $exponent);

echo $return;
8.000000