|
|
@ -94,6 +94,12 @@ BufferReader.prototype.readUInt64LEBN = function() { |
|
|
|
var second = this.buf.readUInt32LE(this.pos); |
|
|
|
var first = this.buf.readUInt32LE(this.pos + 4); |
|
|
|
var combined = (first * 0x100000000) + second; |
|
|
|
// Instantiating an instance of BN with a number is faster than with an
|
|
|
|
// array or string. However, the maximum safe number for a double precision
|
|
|
|
// floating point is 2 ^ 52 - 1 (0x1fffffffffffff), thus we can safely use
|
|
|
|
// non-floating point numbers less than this amount (52 bits). And in the case
|
|
|
|
// that the number is larger, we can instatiate an instance of BN by passing
|
|
|
|
// an array from the buffer (slower) and specifying the endianness.
|
|
|
|
var bn; |
|
|
|
if (combined <= 0x1fffffffffffff) { |
|
|
|
bn = new BN(combined); |
|
|
|