Make PHP's bc round instead of truncate?
質問
I'd like bcadd(4.9,3)
to return 8
rather than 7
. I'm using an example without lots of decimal places here, but the basic idea (that I want to round, rather than truncate) still stands. How do I do this?
正しい解決策はありません
他のヒント
bcadd
lets you specify precision (and bcscale
). You can change it to bcadd(4.9,3,$some_huge_number)
if you have a decimal max .. then you can just use round()
.
所属していません StackOverflow