How does the Discount function round the price of each line item?

Here I have an output of 25% discount for products in the cart,
The 2 target lines are 2 variants of the same product, and have the same price of 39.99 USD. But somehow it was deducted different amounts.
The first variant is deducted $10, the second variant is deducted $9.99 while they have the same price, and the same calculation (39.99 * 25%).
This is confusing for users and conflicts with what I’m showing in the preview to the user.
Please help me explain this and give me the formula by which you determine the discount or rounding amount.

k
Thank you !

I see that this is a very old post, but for anyone else reading this who is wondering the same thing, it’s actually quite straight forward when you consider the cart as a whole…

So $39.99 * 25% is $9.9975 which is rounded up to £10.00

But we have actually given the customer $0.0025 too much discount…

So when the next lien is calculated we also have $39.99 * 25% is $9.9975, but before we do any rounding, we must apply the $0.0025 carried forward from the first item. We gave too much discount for item 1, so we must deduct this from item 2, so we have $9.9975 - $0.0025 =$9.995 which is rounded down to $9.99

But let’s look at this another way. Consider the cart as a whole, we have 2 items at $39.99 = $79.98 and we apply a 25% discount to them which is $19.995, rounded down to $19.99

So price to pay is $79.98 - £19.99 = $59.99

So whilst the individual items appear to be wrong, the overall price charged is correct.

Confusing for customers perhaps…but correct. Might be clearer with a “total discount” line in the totals showing 25% of $79.98 = $19.99