gpt4 book ai didi

PHP|BCMath : How to get bcscale value?

转载 作者:可可西里 更新时间:2023-11-01 12:34:58 26 4
gpt4 key购买 nike

如何在 BCMath 的 bcscale() 方法中获取比例集?

例子:

bcscale(25);

如何获得 25?谢谢!

最佳答案

更新: As of PHP 7.3.0您可以不带参数调用 bcscale() 函数:

var_dump(bcscale()); // int(25)

在 PHP 7.3.0 之前,您首先可以尝试读取 bcmath.scale INI 设置,默认为 0:

$scale = ini_get('bcmath.scale');

由于调用 bcscale() 没有改变 bcmath.scale INI 设置,所以获取当前比例因子的唯一方法是使用这样的解决方法:

$scale = strlen(bcsqrt('2')) - 2;
var_dump($scale); // int(25)

关于PHP|BCMath : How to get bcscale value?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17809336/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com