Hacker News new | ask | show | jobs
by HelloNurse 1339 days ago
Under the hood they might prefer to do accounting in floating point. BigDecimal isn't meant for true programmers.
3 comments

My life got infinitely easier once I learnt the financial world all use integers in cents to do their money calculations.
Is that the case? I was under the impression that Decimals were used in financial contexts because (besides preventing floating point error) you can define how to handle things such as rounding behavior.

For instance, at least in Python, 3//2 == 1 while -3//2 == -2; integer division is rounded down, and not towards zero as one may expect. Decimal lets you pick how you want that to go.

Generally decicents (10 decicents = 1 cent) makes all normal currency calculations much easier/reliable. If you need lower resolution use millicents or microcents
Not all, many situations make use of prices and calculations in the fractions of a cent. For example forex trading, or even gas stations.
still those probably are treated as Integer of a millionth cent
Ah yes when the system thinks you owe them 0.0000000001
Would someone please think of the performanz!