Firefox gets BigInt, and bigint-money gets 1.0 release
My current job is in finance, and the workarounds for dealing with big integers in browsers have been a bit frustrating.
Since my last blogpost, the following features were added:
- Before all rounding was done using ‘Bankers Rounding’ a.k.a. ‘round half to odd’, but since then support has been added for other rounding methods such as ‘half away from 0’, ‘half towards 0’ and ‘truncate’.
- New comparison functions:
isGreaterThanOrEqual(). All of this could be done before with the
compare()function, but these functions will make your source a lot easier to read.
- More precision. In the past I picked an arbitrary maximum precision of 12 decimals, because it felt like this should be enough for any currencies I could find. Since then I actually ran into cases where I needed more. ERC-20 and Ethereum actually use up to 18 decimals. The new default is a precision of 20 decimals.
sign()methods, contributed by flacktack, which behave similar to
If you’re interested, check out the project on Github.