
在 PHP 中,bcsqrt() 函数用于获取任意精度数字的平方根。它接受任意精度数字作为字符串,并在将结果缩放到指定精度后给出该数字的平方根。
语法
string bcsqrt($num_string, $scale)
参数
bcsqrt()函数接受两个不同的参数:$num_string和$scale。 p>
$num_string - 它表示要计算其平方根的数字。字符串类型参数。
$scale − 表示输出中小数点后出现的位数。 p>
返回值
bcsqrt()函数以字符串形式返回数字的平方根。
示例1输出
Output without scale value: 4
示例 2
输出
Output with scale value: 4.690











