Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Also in Fintech. In some cases it is actually necessary to have more than 2 decimal places.

For example, interest accrued daily, but only ‘compounded’ monthly. In those cases, it is necessary to maintain far more than the 2 decimal places for the daily accruals.

The best type to use here would be BigDecimal or equivalent. These ultimately serialise to infinite length strings.



Totally agree on the interest use case, that's exactly where precision beyond 2 decimal places is needed. For payments specifically it makes sense to keep it at 2 because all the payment systems in the US have that precision. When we do build support for ledgers we've considered a few approaches for how that might be serialized. For example we sometimes deal with MasterCard data that tags every amount with an exponent field so something like 1.2345 might be serialized as

  { "amount": 12345, "exponent": 4 }
We could do that or something like:

  { "amount": "1.2345" }




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: