Hello all,
I need to do some price calculations. The function I wrote works perfect in respect of mathematical correctness, but sometimes seems not to work in respect of price calculation. Well, I had no calculation errors for months, but today I had to calculate some prices and I run into an calculation error (1 cent in total sum) which seems to be a kind of exception.
net price 13.78, VAT 7% = gross 14.75 (this is the fact)
Now calculation (with PHP and calculator)
calculate gross: 13.78 * 1.07 = 14.7446000000000001506351 rounded = 14.74
calculate net: 14.75 / 1.07 = 13.7850467289719613717125 rounded = 13.79
I mean, depending on the direction you get different results.
This causes an error when adding prices, at least of 1 cent.
Does anybody know how I could solve this dilemma?
Thanks in advance
Ralf