Comparing version 0.5.4 to 0.6.0
{ | ||
"name" : "bignum", | ||
"version" : "0.5.4", | ||
"version" : "0.6.0", | ||
"description" : "Arbitrary-precision integer arithmetic using OpenSSL", | ||
@@ -5,0 +5,0 @@ "main" : "./index.js", |
@@ -428,14 +428,31 @@ var assert = require('assert'); | ||
exports.endian = function () { | ||
var a = bignum(0x0102030405); | ||
assert.eql(a.toBuffer({ endian: 'big', size: 2 }).toString('hex'), '000102030405'); | ||
assert.eql(a.toBuffer({ endian: 'little', size: 2 }).toString('hex'), '010003020504'); | ||
var a = bignum(0x0102030405); | ||
assert.eql(a.toBuffer({ endian: 'big', size: 2 }).toString('hex'), '000102030405'); | ||
assert.eql(a.toBuffer({ endian: 'little', size: 2 }).toString('hex'), '010003020504'); | ||
var b = bignum(0x0102030405); | ||
assert.eql(a.toBuffer({ endian: 'big', size: 'auto' }).toString('hex'), '0102030405'); | ||
assert.eql(a.toBuffer({ endian: 'little', size: 'auto' }).toString('hex'), '0504030201'); | ||
var c = new Buffer("000102030405", 'hex'); | ||
assert.eql(bignum.fromBuffer(c, { endian: 'big', size: 'auto'}).toString(16), "0102030405"); | ||
assert.eql(bignum.fromBuffer(c, { endian: 'little', size: 'auto'}).toString(16), "050403020100"); | ||
}; | ||
var b = bignum(0x0102030405); | ||
assert.eql(a.toBuffer({ endian: 'big', size: 'auto' }).toString('hex'), '0102030405'); | ||
assert.eql(a.toBuffer({ endian: 'little', size: 'auto' }).toString('hex'), '0504030201'); | ||
exports.bitlength = function () { | ||
var bl = bignum( | ||
'433593290010590489671135819286259593426549306666324008679782084292' | ||
+ '2446494189019075159822930571858728009485237489829138626896756141' | ||
+ '873895833763224917704497568647701157104426' | ||
).bitLength(); | ||
assert.equal(bl > 0, true); | ||
}; | ||
var c = new Buffer("000102030405", 'hex'); | ||
assert.eql(bignum.fromBuffer(c, { endian: 'big', size: 'auto'}).toString(16), "0102030405"); | ||
assert.eql(bignum.fromBuffer(c, { endian: 'little', size: 'auto'}).toString(16), "050403020100"); | ||
} | ||
exports.gcd = function () { | ||
var b1 = bignum('234897235923342343242'); | ||
var b2 = bignum('234790237101762305340234'); | ||
var expected = bignum('6'); | ||
assert.equal(b1.gcd(b2).toString(), expected.toString()); | ||
}; | ||
@@ -442,0 +459,0 @@ if (process.argv[1] === __filename) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
65963
1023
315