moneyphp / money

PHP implementation of Fowler's Money pattern.
http://moneyphp.org
MIT License
4.6k stars 440 forks source link

Rounding up / down as an operation? #681

Closed tyteen4a03 closed 2 years ago

tyteen4a03 commented 2 years ago

How do I round a price up/down to the nearest integer as an operation? round() seems to be a function but it's private so I can't use it in userland.

frederikbosch commented 2 years ago

You pass the rounding mode with operations like multiply and divide. Further, see.

$money->multiply(1.2, Money::ROUND_HALF_UP);