top | item 46082182

Decimal Is Sometimes Wrong

10 points| jt-hill | 3 months ago |jt-hill.com

3 comments

order

benrutter|3 months ago

I enjoyed reading this! It's not always possible but finance data that translates directly into cents/euro-cents/pence/yen/etc is really nice to work with as integers. Obviously as soon as you need to divide that stops being such a solid strategy though. . .

jt-hill|3 months ago

Thanks! And you're right this is true for storage and at the transaction level where nothing smaller than, e.g., a penny is allowed to move or exist in the first place. But when you're working with interest rates and the main calculations involve multiplying by numbers < 1, you still have to figure out rounding.