Closed f0o closed 2 years ago
You are using the JavaScript equality operators ==
and ===
here. You should not rely on the JavaScript equality operators to do these comparisons, they do not know how to handle BigNumbers (or other non-primitive data types). The JavaScript operators for example compare the instance reference instead of the numeric value of the BigNumber.
To compare BigNumbers, you can for use:
math.equal(a, b)
function (can handle BigNumber, number etc, also in mixed use)a.equals(b)
method available on a BigNumber (only working for BigNumbers)math.evaluate(['ONE = bignumber(1)', 'ONE + ONE == ONE + ONE'])
Is there a way to compare two BigNumbers without casting them into Number which might screw them up?