Skip to content

Commit

Permalink
fix: Always return matching signed/unsigned zeroes, fixes #72
Browse files Browse the repository at this point in the history
  • Loading branch information
dcodeIO committed Oct 28, 2021
1 parent bd8e614 commit 19ac17b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions index.js
Expand Up @@ -236,7 +236,7 @@ function fromString(str, unsigned, radix) {
if (str.length === 0)
throw Error('empty string');
if (str === "NaN" || str === "Infinity" || str === "+Infinity" || str === "-Infinity")
return ZERO;
return unsigned ? UZERO : ZERO;
if (typeof unsigned === 'number') {
// For goog.math.long compatibility
radix = unsigned,
Expand Down Expand Up @@ -878,7 +878,7 @@ LongPrototype.sub = LongPrototype.subtract;
*/
LongPrototype.multiply = function multiply(multiplier) {
if (this.isZero())
return ZERO;
return this;
if (!isLong(multiplier))
multiplier = fromValue(multiplier);

Expand All @@ -892,7 +892,7 @@ LongPrototype.multiply = function multiply(multiplier) {
}

if (multiplier.isZero())
return ZERO;
return this.unsigned ? UZERO : ZERO;
if (this.eq(MIN_VALUE))
return multiplier.isOdd() ? MIN_VALUE : ZERO;
if (multiplier.eq(MIN_VALUE))
Expand Down

0 comments on commit 19ac17b

Please sign in to comment.