2.13.1
This version adds the possibility to specify the rounding method for multiply()
and divide()
, and also fixes a bug with the divideAndRound()
function when the divisor is negative.
More details from @gidonkatten’s PR (see #13):
The default behaviour for the multiply and divide operations was to
ROUND_HALF
. Added the possibility to specify whether toROUND_UP
orROUND_DOWN
. Rounding down is especially important as that is the typical behaviour in smart contract opcodes (EVM and non-EVM alike).Also fixed a bug in the
divideAndRound
function (which is called by many operations) when the divisor is negative. E.g.divideAndRound(-15n, 2n)
) anddivideAndRound(15n, -2n)
yielded different results.
Thanks @gidonkatten 🙏