首页 > Web开发 > 详细

php怎么向上取整以5为界

时间:2020-04-29 13:11:40      阅读:76      评论:0      收藏:0      [点我收藏+]
public function test(){
    $number = 52093;
    var_dump( $this->roundNumberVariant( ( int ) $number ) );
}
 
private function roundNumberVariant( $number ){
    //注意:因涉及乘除运算,为了避免知普通计算导致的不精确问题,直接使用BC库函数
    return ( int ) bcmul( ceil( bcdiv( $number , 5000 , 4 ) ) , 5000 );
}

  

php怎么向上取整以5为界

原文:https://www.cnblogs.com/kuba8/p/12801121.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!