略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: bcsqrt

2024-04-29

bcsqrt

(PHP 4, PHP 5, PHP 7, PHP 8)

bcsqrt任意精度数字的二次方根

说明

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

返回 num 的二次方根。

参数

num

字符串类型的操作数。

scale

此可选参数用于设置结果中小数点后的小数位数。也可通过使用 bcscale() 来设置全局默认的小数位数,用于所有函数。如果未设置,则默认为 0

返回值

以 string 类型返回二次方根的结果,如果 num 是负数则返回 null

更新日志

版本 说明
8.0.0 现在 scale 可以为 null。

范例

示例 #1 bcsqrt() 示例

<?php

echo bcsqrt('2'3); // 1.414

?>

参见

  • bcpow() - 任意精度数字的乘方
add a noteadd a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/function.bcsqrt.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3