【发布时间】:2017-11-21 00:42:41
【问题描述】:
我有这个号码:
$total = '0.04149951583898188';
我只想显示点后的前 8 位数字,如下所示:0.0414995
我该怎么做?
【问题讨论】:
-
你甚至没有指定目标语言。
标签: printing
我有这个号码:
$total = '0.04149951583898188';
我只想显示点后的前 8 位数字,如下所示:0.0414995
我该怎么做?
【问题讨论】:
标签: printing
这是我的答案,从您的个人资料和代码 sn-p 猜测您可能在谈论 PHP。不要忘记告诉我们您需要哪种语言的帮助,我们不必猜测!
看看 PHP 的 round() 函数:
<?php
$total = '0.04149951583898188';
echo round((float)$total, 8); // Cast the $total string variable to a type float, and round it
?>
【讨论】: