Comparing version 0.13.1 to 0.13.2
@@ -870,2 +870,12 @@ // Utils | ||
BN.prototype.iabs = function iabs() { | ||
this.sign = false; | ||
return this | ||
}; | ||
BN.prototype.abs = function abs() { | ||
return this.clone().iabs(); | ||
}; | ||
BN.prototype._wordDiv = function _wordDiv(num, mode) { | ||
@@ -872,0 +882,0 @@ var shift = this.length - num.length; |
{ | ||
"name": "bn.js", | ||
"version": "0.13.1", | ||
"version": "0.13.2", | ||
"description": "Big number implementation in pure javascript", | ||
@@ -5,0 +5,0 @@ "main": "lib/bn.js", |
@@ -68,2 +68,14 @@ var assert = require('assert'); | ||
describe('iaddn', function() { | ||
it('should allow a sign change', function() { | ||
var a = new BN(-100) | ||
assert.equal(a.sign, true) | ||
a.iaddn(200) | ||
assert.equal(a.sign, false) | ||
assert.equal(a.toString(), '100') | ||
}) | ||
}) | ||
it('should subtract numbers', function() { | ||
@@ -109,2 +121,22 @@ assert.equal(new BN(14).sub(new BN(26)).toString(16), '-c'); | ||
describe('isubn', function() { | ||
it('should work for positive numbers', function() { | ||
var a = new BN(-100) | ||
assert.equal(a.sign, true) | ||
a.isubn(200) | ||
assert.equal(a.sign, true) | ||
assert.equal(a.toString(), '-300') | ||
}) | ||
it('should not allow a sign change', function() { | ||
var a = new BN(-100) | ||
assert.equal(a.sign, true) | ||
assert.throws(function() { | ||
a.isubn(-200) | ||
}, /Sign change is not supported in isubn/) | ||
}) | ||
}) | ||
it('should mul numbers', function() { | ||
@@ -240,2 +272,8 @@ assert.equal(new BN(0x1001).mul(new BN(0x1234)).toString(16), | ||
it('should absolute numbers', function() { | ||
assert.equal(new BN(0x1001).abs().toString(), '4097'); | ||
assert.equal(new BN(-0x1001).abs().toString(), '4097'); | ||
assert.equal(new BN('ffffffff', 16).abs().toString(), '4294967295'); | ||
}) | ||
it('should modn numbers', function() { | ||
@@ -242,0 +280,0 @@ assert.equal(new BN('10', 16).modn(256).toString(16), '10'); |
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
62575
2005