Make PHP's bc round instead of truncate?
Question
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?
No correct solution
OTHER TIPS
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()
.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow