update bn.js to latest version

...and correspondingly get rid of Number->String conversion

See: https://github.com/indutny/bn.js/issues/17
This commit is contained in:
Ryan X. Charles 2014-07-15 11:25:18 -07:00
parent e75267bd01
commit 0251d467c4
3 changed files with 8 additions and 3 deletions

View File

@ -4,8 +4,6 @@ var bnjs = function bnjs_extended(n) {
if (!(this instanceof bnjs_extended)) { if (!(this instanceof bnjs_extended)) {
return new bnjs(n); return new bnjs(n);
} }
if (typeof n === 'number')
n = n.toString();
arguments[0] = n; arguments[0] = n;
return _bnjs.apply(this, arguments); return _bnjs.apply(this, arguments);
}; };

View File

@ -64,7 +64,7 @@
"mocha": ">=1.15.1", "mocha": ">=1.15.1",
"sjcl": "=1.0.1", "sjcl": "=1.0.1",
"hash.js": "=0.3.1", "hash.js": "=0.3.1",
"bn.js": "=0.13.2", "bn.js": "=0.13.3",
"elliptic": "=0.15.7", "elliptic": "=0.15.7",
"bindings": "=1.1.1", "bindings": "=1.1.1",
"bufferput": "git://github.com/bitpay/node-bufferput.git", "bufferput": "git://github.com/bitpay/node-bufferput.git",

View File

@ -18,6 +18,13 @@ describe('Bignum', function() {
bn.toString().should.equal('999970000'); bn.toString().should.equal('999970000');
}); });
it('should parse numbers below and at bn.js internal word size', function() {
var bn = new Bignum(Math.pow(2, 26) - 1);
bn.toString().should.equal((Math.pow(2, 26) - 1).toString());
var bn = new Bignum(Math.pow(2, 26));
bn.toString().should.equal((Math.pow(2, 26)).toString());
});
describe('#add', function() { describe('#add', function() {
it('should add two small numbers together', function() { it('should add two small numbers together', function() {