royNiladri / js-big-decimal

Work with large numbers on the client side with high precision.
https://www.npmjs.com/package/js-big-decimal
MIT License
156 stars 28 forks source link

Function compareTo fails when comparing 0 and -0 #122

Closed joaoccruz closed 10 months ago

joaoccruz commented 10 months ago

Describe the bug Attempting to run bigDecimal.compareTo("-0", "0") returns -1, assuming -0 is lower than 0, when they are mathematically equal. This is always true, on the cases I tested, even when applying exponentials to either of the two operands.

Package version: 2.0.4

To Reproduce bigDecimal.compareTo("-0", "0") === -1

true

Expected behavior One would expect that compareTo would return 0 (equal) for the operations bigDecimal.compareTo("-0", "0") and bigDecimal.compareTo("0", "-0").

royNiladri commented 10 months ago

Fixed in v2.0.7