Hacker News new | ask | show | jobs
by krystofee 636 days ago
It would be if it did any arithmetic. But maybe it works without any computation. Then the fp arithmetic is not a problem. Or could you provide an example?
1 comments

Neither 0.1 nor 0.01 are representable exactly in binary (much like 1/3 is not representable exactly in decimal). Thus means that your cents, if any, are never precise. Not a big deal for Swift transfers where you can safely round to cents. But various commissions, taxes, and fees are often very small fractions, and rounding errors become noticeable with large quantities of small amounts added / subtracted. They may be too small to matter financially, but they are bothersome because your sums do not match exactly where they should, and this affects trust to the system.

IDK about banks; in one billing system where I was involved we used decimals (and clear rules of assignment of the rounding errors), in another, all amounts were in picodollars.

Yeah, they are not, but still, afaik when I have 0.1 or 0.01 in some variable and pass it around the system it doesn't suddenly change to 0.10000000000012 (or whatever), but the problem arises in case you want to make arithmetic with it, like 0.1 + 0.2 !== 0.3, which you do not do in this library, you just pass "calculated" value how much to send where and you are done.

Partially Im just playing the devils advocate here, I know that you have to use Decimals for working with prices etc., (maybe they did not use it because it will be pretty fat dependency), but still imho it's not needed.