MikeMcl / bignumber.js

A JavaScript library for arbitrary-precision decimal and non-decimal arithmetic
http://mikemcl.github.io/bignumber.js
MIT License
6.64k stars 741 forks source link

Add signum #320

Open Azmisov opened 2 years ago

Azmisov commented 2 years ago

Would be nice to add this:

// returns +/-1 giving the number's sign, except when value is zero, in which +/-0 is returned
P.signum = function () {
    return !!this.c && this.c[0] == 0 ? this.s*0 : this.s;
};

(May be a better way to just return the signed zero value)