You need to sign in to view this topic
This topic created in 4809 days ago, the information mentioned may be changed or developed.
<?php
$a=56;
$b=12;
$c=$a/$b;
echo $c;
?>
输出4.6666666666667
<?php
$a=56;
$b=12;
$c=(int)($a/$b);
echo $c;
?>
输出4
所以不是四舍五入?
10 replies • 1970-01-01 08:00:00 +08:00
 |
|
1
LincolnDz Jun 12, 2013
int是强制整形,只取整数部分 怎么变成四舍五入了.... 四舍五入要用round() float round ( float val [, int precision])
|
 |
|
2
qiayue Jun 12, 2013
我发现楼主问的问题在php手册里边都可以找到,建议多翻翻手册
|
 |
|
4
raincious Jun 12, 2013
echo intval(1.455555); // 1 echo round(1.55555, 0); // 2 echo ceil(1.11111); // 2
|