3 ms·
Currency quantities are inherently exact. If you're doing epsilon comparisons on currency quantities, you are making a fundamental ontological error.
by wyager 4y ago
Currency quantities are inherently exact. If you're doing epsilon comparisons on currency quantities, you are making a fundamental ontological error.
- CamperBob2 4y agoNobody gives a hoot about 0.000001 cents. Round to the nearest 1/100 cent after adding or subtracting doubles, and you will be fine in 99.99999% of applications. The cardinal sin isn't using doubles for currency; it's using them without understanding either the tool or the job that you're asking the tool to perform.
- wyager 4y agoYou've clearly never worked with accountants.
- CamperBob2 4y ago[Citation needed]
- mths 4y agoYou've clearly never worked with accountants. [1] [1] https://news.ycombinator.com/item?id=34717487 https://news.ycombinator.com/item?id=34717487
- CamperBob2 4y agoI don't know what I expected
- 8n4vidtmkvmk 4y agoI've been using doubles for currency knowing full well that i probably shouldn't. for 8 years now. so far I've only noticed being off by a cent here and there. yep.. just don't care. will cost more than a penny to fix it now.
- lmm 4y agoDepends what you're doing with them. A value at risk calculation gives you a currency-dimensioned result that's hard to represent exactly, for example.
- wyager 4y agoYes, a more precise statement is "exact currency amounts form a group under addition" - once you depart from group operations (e.g. multiplication by non-integral scalars) you can start to consider floats.