您的位置 首页 php

php round函数的实际应用(附示例)

php round函数的实际应用(附示例)

php round函数定义和用法

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

语法

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函数怎么用的详细内容,希望大家观看以后有所收益。

————————————————

版权声明:本文为CSDN博主「佰草」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。

原文链接:https://blog.csdn.net/weixin_44007570/article/details/90770878

推荐教程:《PHP教程》

以上就是php round函数的实际应用(附示例)的详细内容,更多请关注求知技术网其它相关文章!

文章来源:智云一二三科技

文章标题:php round函数的实际应用(附示例)

文章地址:https://www.zhihuclub.com/6256.shtml

关于作者: 智云科技

热门文章

评论已关闭

1条评论

  1. No matter if some one searches for his vital thing, therefore
    he/she desires to be available that in detail, therefore that thing
    is maintained over here.

网站地图