Skip to content

Commit 19ac17b

Browse files
committed
fix: Always return matching signed/unsigned zeroes, fixes #72
1 parent bd8e614 commit 19ac17b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ function fromString(str, unsigned, radix) {
236236
if (str.length === 0)
237237
throw Error('empty string');
238238
if (str === "NaN" || str === "Infinity" || str === "+Infinity" || str === "-Infinity")
239-
return ZERO;
239+
return unsigned ? UZERO : ZERO;
240240
if (typeof unsigned === 'number') {
241241
// For goog.math.long compatibility
242242
radix = unsigned,
@@ -878,7 +878,7 @@ LongPrototype.sub = LongPrototype.subtract;
878878
*/
879879
LongPrototype.multiply = function multiply(multiplier) {
880880
if (this.isZero())
881-
return ZERO;
881+
return this;
882882
if (!isLong(multiplier))
883883
multiplier = fromValue(multiplier);
884884

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

894894
if (multiplier.isZero())
895-
return ZERO;
895+
return this.unsigned ? UZERO : ZERO;
896896
if (this.eq(MIN_VALUE))
897897
return multiplier.isOdd() ? MIN_VALUE : ZERO;
898898
if (multiplier.eq(MIN_VALUE))

0 commit comments

Comments
 (0)