We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8b42737 commit 600eaa9Copy full SHA for 600eaa9
lib/js/bn.js
@@ -186,7 +186,7 @@ class BN {
186
187
// Possible sign change.
188
if (this.negative !== 0) {
189
- if (this.length === 1 && (this.words[0] | 0) < num) {
+ if (this.length === 1 && (this.words[0] | 0) <= num) {
190
this.words[0] = num - (this.words[0] | 0);
191
this.negative = 0;
192
return this;
test/bn-test.js
@@ -411,6 +411,11 @@ describe('BN.js', function() {
411
new BN(0).iaddn(0x4000000);
412
});
413
414
+
415
+ it('should reset sign if value equal to value in instance', function () {
416
+ const a = new BN(-1);
417
+ assert.equal(a.addn(1).toString(), '0');
418
+ });
419
420
421
describe('.sub()', () => {
0 commit comments