Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

php
communitycreator

What is bcsqrt in PHP?

Sheza Naveed

bcsqrt() is a function in PHP that calculates the square root of an arbitrary precision number.

Syntax

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

Parameters

  • 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.

Return value

The square root of the parameter passed is returned by the function.

null is returned if num is less than zero.

Code

<?php
$num = bcsqrt('2', 3);
echo $num;
?>

Output

1.414

RELATED TAGS

php
communitycreator
RELATED COURSES

View all Courses

Keep Exploring