PHP | bcsqrt() Function Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report The bcsqrt() function in PHP is an inbuilt function and is used to evaluate the square root of an arbitrary precision number. This function accepts an arbitrary precision number as a string and returns the square root of the number after scaling the result to a specified precision. Syntax: string bcsqrt ( $num_str, $scaleVal) Parameters: This function accepts three parameters as shown in the above syntax and explained below: $num_str: This parameter is of string type and represents the operand or a number whose square root is to be evaluated. This parameter is mandatory. $scaleVal: This parameter is of int type and is optional. This parameter tells the number of digits that will appear after the decimal in the result. It's default value is zero. Return Value: This function returns the square root of a number $num_str as string. Examples: Input: $num_str = 26 Output: 5 Since the parameter $scaleVal is not specified so no digits after decimal is appeared in the result after finding out square root. Input: $num_str = 26, $scaleVal = 4 Output: 5.0990 Below programs illustrate the bcsqrt() function in PHP : Program 1: php <?php // PHP program to illustrate bcsqrt() function // input numbers with arbitrary precision $num_str = "26"; // calculates the square root when // $scaleVal is not specified $res = bcsqrt($num_str); echo $res; ?> Output: 5 Program 2: php <?php // PHP program to illustrate bcsqrt() function // input numbers with arbitrary precision $num_str = "26"; $scale = "4"; // calculates the square root when // $scaleVal is specified $res = bcsqrt($num_str, $scale); echo $res; ?> Output: 5.0990 Reference: https://www.php.net/manual/en/function.bcsqrt.php Comment More infoAdvertise with us Next Article PHP | bcscale() Function C ChetnaAgarwal Follow Improve Article Tags : Web Technologies PHP PHP-bc Similar Reads PHP cos( ) Function Trigonometry is an important part of mathematics and PHPâs math functions provides us with some functions which are very useful for calculations involving trigonometry. The cos()function in PHP is used to find the cosine of a number. The cos() function returns a float value between -1 and 1, which r 2 min read PHP acos( ) Function Trigonometry is an important part of mathematics and PHPâs math functions provides us with some functions which are very useful for calculations involving trigonometry. One of such function is acos() function. The acos() function in PHP is used to find the arc cosine of a number in radians. We alrea 2 min read PHP | bcscale() Function The bcscale() function is an inbuilt function in PHP. It sets the default scale parameters for all bc math function calls. When we call the function bcscale() in a program, the parameter passed in this function thus becomes the default scale factor which by default is zero. Syntax: int bcscale($scal 2 min read PHP | bcscale() Function The bcscale() function is an inbuilt function in PHP. It sets the default scale parameters for all bc math function calls. When we call the function bcscale() in a program, the parameter passed in this function thus becomes the default scale factor which by default is zero. Syntax: int bcscale($scal 2 min read PHP | bcmod() Function The bcmod() function in PHP is an inbuilt function and is used to calculate modulus of an arbitrary precision numbers. This function accepts an arbitrary precision number and returns the modulus of that number after scaling the result to a specified precision. Syntax: string bcadd ( $dividend, $modu 2 min read PHP | bcmod() Function The bcmod() function in PHP is an inbuilt function and is used to calculate modulus of an arbitrary precision numbers. This function accepts an arbitrary precision number and returns the modulus of that number after scaling the result to a specified precision. Syntax: string bcadd ( $dividend, $modu 2 min read Like