News for hackers. Stuff that matters.
Re:Engineering Principles for Building Financial Systems by alphalima on Thursday July 11, 2024 @03:56AM (#40934545)
On the best practices, as noted by others, there are probably classes in your standard lib/ commons lib that cover this stuff better than storing in integers (e.g. BigDecimal in Java and Python Decimal have precision and rounding mode concepts built in).

Something I've found valuable is on is managing euler units/ratios (e.g. proportions 10^1, percentages 10^-2, basis points 10^-4) . Enforcing a standard that all interchange, data storage has either the same scale, _or is stored with its scale (and not in the name)_ will reduce errors hugely significantly.

Re:Engineering Principles for Building Financial Systems by eru on Thursday July 11, 2024 @05:25AM (#40934913)
You standard library might even already have libraries for eg storing currencies or time, too.
Re:Engineering Principles for Building Financial Systems by dennis_jeeves2 on Saturday July 13, 2024 @05:04AM (#40952755)
Just FYI here: To the extent that I explored even BigDecimal in Java falls short when it comes to the calculations. It does do well on the rounding. There might be other libraries that are better when it comes to calculations. If those libraries don't exist integers are the way the go.