php中float转int的方法
来源:动视网
责编:小采
时间:2020-11-02 22:06:58
php中float转int的方法
php中float转int的方法:php中float转int的方法使用round(x,prec)方法参数描述x可选。规定要舍入的数字。prec可选。规定小数点后的位数<php echo(round(0.60)); echo(round(0.50)); echo(round(0.49)); echo(round(-4.40)); echo(roun
导读php中float转int的方法:php中float转int的方法使用round(x,prec)方法参数描述x可选。规定要舍入的数字。prec可选。规定小数点后的位数<php echo(round(0.60)); echo(round(0.50)); echo(round(0.49)); echo(round(-4.40)); echo(roun

php中float转int的方法
使用round(x,prec)方法
参数 | 描述 |
x | 可选。规定要舍入的数字。 |
prec | 可选。规定小数点后的位数 |
<?php
echo(round(0.60));
echo(round(0.50));
echo(round(0.49));
echo(round(-4.40));
echo(round(-4.60));
输出:
1
1
0
-4
-5
推荐教程: 《php教程》
php中float转int的方法
php中float转int的方法:php中float转int的方法使用round(x,prec)方法参数描述x可选。规定要舍入的数字。prec可选。规定小数点后的位数<php echo(round(0.60)); echo(round(0.50)); echo(round(0.49)); echo(round(-4.40)); echo(roun