2 ms·
Because if you do all of your internal calculations in cents, then the rounding errors add up to a significant amount in not very much time. Let's say you have
by lambda 13y ago
Because if you do all of your internal calculations in cents, then the rounding errors add up to a significant amount in not very much time.
Let's say you have a service that is $20 per year. That is 5.475¢ per day (I'm assuming a year of 365.242 days; if you do an integral number of days and account for leap years, then it will be a different daily rate in regular years and leap years). If you are doing calculations which pro-rate certain things per day, such as allowing people to transition between different subscription types while applying their existing balance to the new subscription, and you rounded that down to 5¢ per day, then when you multiplied that back out to a year it would only be $18.26 per year, not $20 per year. That's a pretty substantial difference.
Where you fix your precision depends on how much error you're willing to deal with. In the article, he describes how using millicents leads to an error of 165m¢ (.165¢) per year, if you apply the rounded daily rate and multiply by the number of days, which is deemed acceptable for their purposes. For a much more extreme example of precision, Tarsnap quotes their prices in picodollars per byte per month (https://www.tarsnap.com/picoUSD-why.html https://www.tarsnap.com/picoUSD-why.html) and performs all calculations in attodollars per byte per day.