将价格四舍五入到最接近的 $xx.99
Round prices to nearest $xx.99
我想将价格四舍五入(向上或向下)到最接近的 $xx.99
例如:
.99 -> Stay as is
.03 -> .99
.85 -> .99
-> .99
加0.01,四舍五入,减0.01
$input = 17.99; // example input
$add = $input + 0.01;
$round = round($add);
$output = $round - 0.01;
或一体机:
return round($input + 0.01) - 0.01;
我想将价格四舍五入(向上或向下)到最接近的 $xx.99
例如:
.99 -> Stay as is
.03 -> .99
.85 -> .99
-> .99
加0.01,四舍五入,减0.01
$input = 17.99; // example input
$add = $input + 0.01;
$round = round($add);
$output = $round - 0.01;
或一体机:
return round($input + 0.01) - 0.01;