我想将价格四舍五入(向上或向下)到最接近的 xx.99 美元
例如:
$17.99 -> Stay as is
$22.03 -> $21.99
$33.85 -> $33.99
$45 -> $44.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;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)