# Extract VAT with ghost cent

I have to write a math calculation to exctract VAT from a gross amount, but I think many online calculator are missing some particular cases.

Let's say we have 10% of VAT and a gross amount of 5.00€ what is the net and vat amount? The rounding rules says that I have to round half up the 5th thousandth.

The standard formula would be:

``````net= 5 / (1 + 10 / 100)
net = 4,545454545454545
net (rounded) = 4.55
``````

The problem is that: 4.55 + 10% = 5.01 and it exceeds the given gross amount

The previous cent has the opposite problem: 4.54 + 10% = 4.99 and it is less then the gross amount

So what is the right formula to exctract VAT?

• I assume the question was written specifically because of this very curious case and the only answer is that it should have been taught beforehand.... To answer the less important question: you just calculate your gross sales at the end of the month/quarter and pay your VAT to the government based on that. Clearly you keep the rounding cent (or you might even be rounding to the nearest dollar, depending on jurisdiction). This is purely hypothetical and not important in actual business – xyious Apr 3 '20 at 18:21
• This is the point, I have to calculate gross/net for the single product sale and after sum all taxes, and not the opposite. This is why the right formula is important here. – Tobia Apr 4 '20 at 7:58

## 2 Answers

If the gross is calculated by adding VAT to an actual base price, than the gross can never be 5.00. A base price of 4.54 will result in a gross of 4.99 and a base price 4.55 in a gross of 5.01.

Your formula doesn't work since there is no base price that can produce a gross of 5.00.

• I agree with you, however I have to develop a software to calculate taxes from a gross price and I cannot understand how to proceed. – Tobia Apr 4 '20 at 7:45

Is it possible that instead of ROUND(VAT, 2 decimal points) that the formula is really FLOOR(VAT, 2 decimal points)?