# How to handle/calculate/store prices with or without VAT in software

My company handles prices and payments through our software where we typically store price without VAT in whole unit with 2 decimal places and VAT with 1 decimal place.

Generally speaking my question is : should we handle/store/manipulate prices with or without VAT, knowing that in practice the price with VAT is often the "base" one and the price without VAT is a consequence of the price with VAT that we choose/want and VAT imposed by regulations even if I know this is supposed to be the other way around.

1/ When we are calculating one of the price from the other and the VAT, should we just always round down, or up, or "naturally" (up when >= 0.5, down when < 0.5), or half-even ?

2/ When we are adding several quantities of the same price, should we work with the value with or without VAT, the rounded value or the exact one ?

Example : we sell a merchandise and we want it to cost 4.99 at 20.0% VAT. Unit price without VAT is 4.1583, or stored and displayed at 4.16.
But what if someone buy 100 of them, should we do `4.16 * 100 * 1.2 = 499.20` or `4.99 * 100 = 499.00` or `4.1583 * 100 * 1.2 = 499.00 (498.996)` ?

Should we convert to with VAT as early as possible and multiply that, or only convert to VAT at the last moment

One solution seems to store prices without VAT with 4 digits of precision, but I find it really weird, because even Stripe don't do that.
And it doesn't prevent some issues because we would still need to round them somehow for display and thus any calculation using that rounded value would be incorrect.
Or is it acceptable to tell customer that we use a value for calculation more precise than the one displayed ?

Another solution seems to actually store the price with VAT, since this is the one we decide, no matter what VAT applies. But this seems uncommon since VAT is supposed to be able to change without affecting the price without VAT...