HACKER Q&A
📣 v-erne

Open-source projects that handle monetary values properly


What are some big Open Source projects that are dealing with monetary values that are worth checking out?

I'm especially intrested in seeing codebases written in Java or Python talking to Postgres and MongoDB with modern web frontend. It would be also interesting to see how javascript (standard and node.js) handles this in production grade code.

I'm aware that there are few strategies for this, but I would like to find out what are consequences of them when codebase grows.


  👤 joshxyz Accepted Answer ✓
For client-side and server-side JS, we use big.js [1].

- We use strict mode [2] so we are forced to only input strings and never numbers.

- We set rounding mode [3] to round-down.

- Finally the default 20 decimal places [4] seems reliable enough for most of our use-cases.

- It's also immutable and we can easily truncate decimal places with toFixed(dp) [5]

[1] https://github.com/MikeMcl/big.js/

[2] http://mikemcl.github.io/big.js/#strict

[3] http://mikemcl.github.io/big.js/#rm

[4] http://mikemcl.github.io/big.js/#dp

[5] http://mikemcl.github.io/big.js/#toF