0

$diff = $choice->GetAmount() - $choice->GetPrice();

If the input for both is equal i.e 1.25 and 1.25 it shows 2.2204460492503E-16 instead of 0

  • 2
    When working with finances, work in cents, not dollars. Avoids floating point math. – ceejayoz Mar 19 '20 at 21:26
  • 1
    _Integer_ values of cents. Never floats. There are libraries that help you deal with money without losing or duplicating pennies. eg: http://moneyphp.org/ – Sammitch Mar 19 '20 at 21:31

0 Answers0