Comparing version 2.0.3 to 2.0.4
@@ -64,3 +64,3 @@ (function (module, exports) { | ||
this.length = 1; | ||
} else { | ||
} else if (number < 0x10000000000000) { | ||
this.words = [ | ||
@@ -71,2 +71,10 @@ number & 0x3ffffff, | ||
this.length = 2; | ||
} else { | ||
assert(number < 0x20000000000000); // 2 ^ 53 (unsafe) | ||
this.words = [ | ||
number & 0x3ffffff, | ||
(number / 0x4000000) & 0x3ffffff, | ||
1 | ||
]; | ||
this.length = 3; | ||
} | ||
@@ -73,0 +81,0 @@ return; |
{ | ||
"name": "bn.js", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"description": "Big number implementation in pure javascript", | ||
@@ -5,0 +5,0 @@ "main": "lib/bn.js", |
@@ -14,2 +14,18 @@ var assert = require('assert'); | ||
}); | ||
it('should accept 52 bits of precision', function() { | ||
var num = Math.pow(2, 52); | ||
assert.equal(new BN(num, 10).toString(10), num.toString(10)); | ||
}); | ||
it('should accept max safe integer', function() { | ||
var num = Math.pow(2, 53) - 1; | ||
assert.equal(new BN(num, 10).toString(10), num.toString(10)); | ||
}); | ||
it('should not accept an unsafe integer', function() { | ||
var num = Math.pow(2, 53); | ||
assert.throws(function() { new BN(num, 10); }); | ||
}); | ||
}); | ||
@@ -16,0 +32,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
211465
15
2997