Always considering rounding direction

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the algorithms category.

Last Updated: 2024-04-28

If you are converting money amounts to cent, don't just convert to integer blindly - e.g. amount_in_cent = int(payment.amount.amount * 100) - think about rounding direction (e.g. rounding down or up)

In a large enough business, rounding up could make many thousands -- if not more -- of difference in a year.