Skip to content

2.13.1

Compare
Choose a tag to compare
@bpierre bpierre released this 04 Jun 19:58
· 4 commits to main since this release
6051ebe

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 to ROUND_UP or ROUND_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)) and divideAndRound(15n, -2n) yielded different results.

Thanks @gidonkatten 🙏