Comparing version 0.14.1 to 0.14.2
@@ -869,3 +869,17 @@ // Utils | ||
if (num < 0) | ||
return this.isubn(num); | ||
return this.isubn(-num); | ||
// Possible sign change | ||
if (this.sign) { | ||
if (this.length === 1 && this.words[0] < num) { | ||
this.words[0] = num - this.words[0]; | ||
this.sign = false; | ||
return this; | ||
} | ||
this.sign = false; | ||
this.isubn(num); | ||
this.sign = true; | ||
return this; | ||
} | ||
this.words[0] += num; | ||
@@ -889,5 +903,12 @@ | ||
assert(typeof num === 'number'); | ||
assert(this.cmpn(num) >= 0, 'Sign change is not supported in isubn'); | ||
if (num < 0) | ||
return this.iaddn(-num); | ||
if (this.sign) { | ||
this.sign = false; | ||
this.iaddn(num); | ||
this.sign = true; | ||
return this; | ||
} | ||
this.words[0] -= num; | ||
@@ -894,0 +915,0 @@ |
{ | ||
"name": "bn.js", | ||
"version": "0.14.1", | ||
"version": "0.14.2", | ||
"description": "Big number implementation in pure javascript", | ||
@@ -5,0 +5,0 @@ "main": "lib/bn.js", |
@@ -139,5 +139,5 @@ var assert = require('assert'); | ||
assert.throws(function() { | ||
a.isubn(-200) | ||
}, /Sign change is not supported in isubn/) | ||
a.isubn(-200); | ||
assert.equal(a.sign, false) | ||
assert.equal(a.toString(), '100') | ||
}) | ||
@@ -144,0 +144,0 @@ }) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
61855
2018