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 !