在 PHP 中显示更多数字 [英] Show more digits in PHP

查看:50
本文介绍了在 PHP 中显示更多数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有:

echo 1/3;

而且它只打印出 0.33333333333333,我能得到更多的数字吗?

And it print out only 0.33333333333333, can I get more digits?

推荐答案

可以使用<代码>bcdiv

echo bcdiv(1, 3, 20);

第三个参数

用于设置结果中小数点后的位数.您还可以使用 bcscale() 为所有函数设置全局默认比例.

is used to set the number of digits after the decimal place in the result. You can also set the global default scale for all functions by using bcscale().

这篇关于在 PHP 中显示更多数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆