php round函数
2022-07-28 14:58:37
191
{{single.collect_count}}

php round函数用于对对浮点数进行四舍五入,其语法是round(x,prec),参数x可选,指规定要舍入的数字;prec可选,指规定小数点后的位数。

php round函数怎么用?

定义和用法

round() 函数对浮点数进行四舍五入。

语法

round(x,prec)

参数

x 可选。规定要舍入的数字。

prec 可选。规定小数点后的位数。

说明

返回将 x 根据指定精度 prec (十进制小数点后数字的数目)进行四舍五入的结果。prec 也可以是负数或零(默认值)。

提示和注释

注释:PHP 默认不能正确处理类似 “12,300.2” 的字符串。

注释:prec 参数是在 PHP 4 中被引入的。。

例子

<?phpecho(round(0.60));echo(round(0.50));echo(round(0.49));echo(round(-4.40));echo(round(-4.60));?>

输出:

110-4-5

以上就是php round函数怎么用的详细内容

回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}