Brick/Money is a money and currency library for PHP that handles exact calculations on monies of any size. So we can use this library that is based on brick/math and handles exact calculations on monies of any size. This library is installable via Composer: composer require brick/money
To create Money, call the of() factory method: use Brick\Money\Money; $money = Money::of(50, 'USD'); // USD 50.00 $money = Money::of('19.9', 'USD'); // USD 19.90 Alternatively, you can create Money from a number of "minor units"(cents), using the ofMinor() method: use Brick\Money\Money; $money = Money::ofMinor(1234, 'USD'); // USD 12.34