bcsqrt()
is a function in PHP that calculates the square root of an arbitrary precision number.
bcsqrt(string $num, int $scale = null): string
num
– parameter of type string
.scale
– parameter 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.The square root of the parameter passed is returned by the function.
null
is returned if num is less than zero.
<?php $num = bcsqrt('2', 3); echo $num; ?>
1.414
RELATED TAGS
CONTRIBUTOR
View all Courses