
在PHP中,bcscale()函数用于设置所有bc math的默认参数 函数。此函数为所有后续调用的bc数学函数设置默认的比例参数,如果没有显式指定比例参数。
int bcscale($scale)
$bcscale() 参数只接受一个参数,它是必需的整数类型参数。该参数表示小数点后的位数。默认值为0。
$bcscale() 函数返回旧的精度值。
<?php
// default scale : 5
bcscale(5);
// The default scale value as 5
echo bcadd('107', '6.5596'), "";
// this is not the same without bcscale()
echo bcadd('107', '6.55957', 1), "";
// the default scale value as 5
echo bcadd('107', '6.55957'), "";
?>113.55960 113.5 113.55957
<?php
// set default scale 5
bcscale(5);
// set the default scale value as 5
echo bcadd('107', '6.5596'), "";
// this is not the same without bcscale()
echo bcadd('107', '6.55957', 1), "";
// Changed the default scale value
bcscale(3);
// the default scale value as 5
echo bcadd('107', '6.55957'), "";
?>113.55960 113.55 113.559
以上就是PHP - 如何使用bcscale()函数设置或获取所有bc数学函数的默认精度参数?的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号