时间:2021-07-01 10:21:17 帮助过:3人阅读
function up6down4($num,$n){ $pow = pow(10,$n); $con_a = floor(round($num * $pow * 10,1)); $con_b = floor(round($num * $pow,1)); $con_c = ($num * $pow * 10); $len = strlen(str_replace('.','',$con_c))-strlen($con_a); //舍去位为5 && 舍去位后无有效数字 && 舍去位前一位是偶数 ->不进位 if(($con_a % 5 == 0) && bccomp($con_a,$con_c,($len))==0 && ($con_b % 2 ==0) ){ return floor($num * $pow)/$pow; }else{//四舍五入 return round($num,$n); }}