MikeMcl / decimal.js

An arbitrary-precision Decimal type for JavaScript
http://mikemcl.github.io/decimal.js
MIT License
6.35k stars 480 forks source link

isPositive() should return false for zero #218

Closed charmbv closed 1 year ago

charmbv commented 1 year ago

Currently the function isPositive() returns true for a zero value. This should be false.

MikeMcl commented 1 year ago

I don't really disagree but this library has signed zeros like JavaScript numbers, and that was an early design decision I have no interest in revisiting.

Decimal(-0).isNegative()    // true
Decimal(0).isPositive()     // true

isZero can be used to detect zero.