logoalt Hacker News

jgalt212 • today at 1:06 PM • 1 reply • view on HN

> Many people know that you shouldn’t do decimal calculations, such as those involving U.S. dollars and cents, with the floating-point numbers in most programming languages. This is because decimal numbers can’t be expressed exactly as such floating-point numbers, so you will encounter rounding errors.

Decimals or pennies, you still have rounding errors. For example, if your contract is $100 / year. You will get the full $100 if you bill yearly, quarterly, or semi-annually. But if you bill monthly, no matter if you deal in pennies or fractional dollars, the sum total of your invoices for the year will be less than $100.


Replies

gottheUIblues • today at 1:29 PM

Bill 8 months at $8.33 and 4 months at $8.34?

➕ show 2 replies