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

bcsqrt

Description

The bcsqrt of BCMath for PHP gets the square root of an arbitrary precision number.

Syntax

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

Parameters

num

The operand, as a well-formed BCMath numeric string.

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 square root as a well-formed BCMath numeric string.

Examples

1 · num

<?

$num = '9';

$return = bcsqrt($num);

echo $return;
3

2 · scale

<?

$num = '9';
$scale = 6;

$return = bcsqrt($num, $scale);

echo $return;
3.000000

3 · bcscale

<?

$scale = 6;

bcscale($scale);

$num = '9';

$return = bcsqrt($num);

echo $return;
3.000000