4 ms·
My favorite: when do you do rounding? For instance, with proration. Take each line item, prorate it, round it, then add them all together. Totally reasonable.
by breischl 6y ago
My favorite: when do you do rounding?
For instance, with proration. Take each line item, prorate it, round it, then add them all together. Totally reasonable.
Now add all the line items together, prorate the total, and round it. Also reasonable, but there's a decent chance the number is different by a few pennies because of rounding differences. If you chained more calculations the differences would compound.
Whichever way you choose, somebody is going to whip out their calculator and tell you that you did it wrong (but only when they come out better the other way).
This applies anywhere you're doing multiplication or division. Discounts, proration, taxes, "cashback", "store credit dividend", whatever.
- ianmcgowan 6y agoIn my world, we keep a running total of the rounded prorated amounts, and then the last item (n) becomes (total - total up to n-1) to make sure amounts match. It can still be a problem if the last value is very small however.
- breischl 6y agoYeah, that's another way to do it. Another way to look at that is you're doing the proration on the final amount, and then distributing the rounding difference across the line items. Which is nice because you get the right total, though it can look weird when line items for the exact same thing are off by a penny from each other.