News for hackers. Stuff that matters.
Re:Ask HN: How to handle financial calculations precisely? by viraptor on Wednesday January 25, 2023 @04:00PM (#34524117)
I think there are mainly 2 scenarios for strict rules. Either you deal with actual financial data and there will be laws around how to do the rounding correctly for each case, or you're doing some analytics and you can just agree on what kind of error is acceptable. You can do the analysis of what the error in the result may be and check with the people who use the result.

So basically there are either rules around the calculation that you're not aware of yet, or you're doing it for some ad-hoc graphs where the answer is "Yolo, just choose some large number for precision".

Re:Ask HN: How to handle financial calculations precisely? by fedeb95 on Wednesday January 25, 2023 @04:07PM (#34524188)
I'm dealing with actual financial data and I don't think there are laws regarding exactly how you should deal with money in terms of specific algorithms. If you have any pointers...
Re:Ask HN: How to handle financial calculations precisely? by viraptor on Wednesday January 25, 2023 @05:01PM (#34524762)
Talk to a local accountant. Even if there's no law for your specific situation, there will be one applicable for the country, or at least a known rule everyone follows that's accepted by the local tax org.