We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c4098ba commit 67ecb35Copy full SHA for 67ecb35
lib/bn.js
@@ -2129,6 +2129,11 @@
2129
this.words[this.length - 1] &= mask;
2130
}
2131
2132
+ if (this.length === 0) {
2133
+ this.words[0] = 0;
2134
+ this.length = 1;
2135
+ }
2136
+
2137
return this.strip();
2138
};
2139
test/binary-test.js
@@ -56,6 +56,8 @@ describe('BN.js/Binary', function () {
56
57
describe('.imaskn()', function () {
58
it('should mask bits in-place', function () {
59
+ assert.equal(new BN(42).imaskn(0).toString(), '0');
60
+ assert.equal(new BN(42).imaskn(0).toString(16), '0');
61
assert.equal(new BN(0).imaskn(1).toString(16), '0');
62
assert.equal(new BN(3).imaskn(1).toString(16), '1');
63
assert.equal(new BN('123456789', 16).imaskn(4).toString(16), '9');
0 commit comments