I'm calculating fees (monetary) for something and PHP is behaving strangely when the amount is supposed to be 0.00. It's giving the final result as a floating number, not 0 which it should be.
In My database I have the following table
id | transaction_total | charge_fees | deposit_fee | amount_to_customer | fees_minus_total_difference
So when I go to check to make sure that the fees + amount paid - total = 0.00
(96.54 + .25 + 3.20 - 99.99) = 1.4210854715202E-14
Why is the result a floating number and not actually zero? The numbers are originally more decimal places, but I used number_format to put it into 2 places. Ex, charge fees may actually be 3.19987
number_format(3.19971,2,'.','') //equals 3.20
When I save this in my database it displays as 3.20. When I use it in the computation for the total/fee check, the result is not zero, albeit close.