Socket
Socket
Sign inDemoInstall

long

Package Overview
Dependencies
0
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.3 to 2.0.0

dist/Long.min.js.gz

4

bower.json
{
"name": "long",
"version": "1.2.0",
"version": "2.0.0",
"author": "Daniel Wirtz <dcode@dcode.io>",
"description": "Long.js: A Long class for representing a 64-bit two's-complement integer value derived from the Closure Library extended with unsigned support.",
"description": "A Long class for representing a 64 bit two's-complement integer value.",
"main": "dist/Long.js",

@@ -7,0 +7,0 @@ "keywords": ["math"],

@@ -17,6 +17,6 @@ /*

*/
/**
* @license Long.js (c) 2013 Daniel Wirtz <dcode@dcode.io>
* Released under the Apache License, Version 2.0
* Derived from goog.math.Long from the Closure Library
* see: https://github.com/dcodeIO/Long.js for details

@@ -28,35 +28,13 @@ */

/**
* Constructs a 64-bit two's-complement integer, given its low and high 32-bit
* values as *signed* integers. See the from* functions below for more
* convenient ways of constructing Longs.
*
* The internal representation of a long is the two given signed, 32-bit values.
* We use 32-bit pieces because these are the size of integers on which
* Javascript performs bit-operations. For operations like addition and
* multiplication, we split each number into 16-bit pieces, which can easily be
* multiplied within Javascript's floating-point representation without overflow
* or change in sign.
*
* In the algorithms below, we frequently reduce the negative case to the
* positive case by negating the input(s) and then post-processing the result.
* Note that we must ALWAYS check specially whether those values are MIN_VALUE
* (-2^63) because -MIN_VALUE == MIN_VALUE (since 2^63 cannot be represented as
* a positive number, it overflows back into a negative). Not handling this
* case would often result in infinite recursion.
*
* Constructs a 64 bit two's-complement integer, given its low and high 32 bit values as *signed* integers.
* See the from* functions below for more convenient ways of constructing Longs.
* @exports Long
* @class A Long class for representing a 64-bit two's-complement integer value.
* @param {number|!{low: number, high: number, unsigned: boolean}} low The low (signed) 32 bits of the long.
* Optionally accepts a Long-like object as the first parameter.
* @param {number=} high The high (signed) 32 bits of the long.
* @param {boolean=} unsigned Whether unsigned or not. Defaults to `false` (signed).
* @class A Long class for representing a 64 bit two's-complement integer value.
* @param {number} low The low (signed) 32 bits of the long
* @param {number} high The high (signed) 32 bits of the long
* @param {boolean=} unsigned Whether unsigned or not, defaults to `false` for signed
* @constructor
*/
var Long = function(low, high, unsigned) {
if (low && typeof low === 'object') {
high = low.high;
unsigned = low.unsigned;
low = low.low;
}
/**

@@ -67,3 +45,3 @@ * The low 32 bits as a signed value.

*/
this.low = low | 0;
this.low = low|0;

@@ -75,3 +53,3 @@ /**

*/
this.high = high | 0;
this.high = high|0;

@@ -86,10 +64,33 @@ /**

// NOTE: Common constant values ZERO, ONE, NEG_ONE, etc. are defined below the from* methods on which they depend.
// The internal representation of a long is the two given signed, 32-bit values.
// We use 32-bit pieces because these are the size of integers on which
// Javascript performs bit-operations. For operations like addition and
// multiplication, we split each number into 16 bit pieces, which can easily be
// multiplied within Javascript's floating-point representation without overflow
// or change in sign.
//
// In the algorithms below, we frequently reduce the negative case to the
// positive case by negating the input(s) and then post-processing the result.
// Note that we must ALWAYS check specially whether those values are MIN_VALUE
// (-2^63) because -MIN_VALUE == MIN_VALUE (since 2^63 cannot be represented as
// a positive number, it overflows back into a negative). Not handling this
// case would often result in infinite recursion.
//
// Common constant values ZERO, ONE, NEG_ONE, etc. are defined below the from*
// methods on which they depend.
// NOTE: The following cache variables are used internally only and are therefore not exposed as properties of the
// Long class.
/**
* Tests if the specified object is a Long.
* @param {*} obj Object
* @returns {boolean}
* @expose
*/
Long.isLong = function(obj) {
return (obj && obj instanceof Long) === true;
};
/**
* A cache of the Long representations of small integer values.
* @type {!Object}
* @inner
*/

@@ -101,2 +102,3 @@ var INT_CACHE = {};

* @type {!Object}
* @inner
*/

@@ -106,6 +108,6 @@ var UINT_CACHE = {};

/**
* Returns a Long representing the given (32-bit) integer value.
* @param {number} value The 32-bit integer in question.
* @param {boolean=} unsigned Whether unsigned or not. Defaults to false (signed).
* @return {!Long} The corresponding Long value.
* Returns a Long representing the given 32 bit integer value.
* @param {number} value The 32 bit integer in question
* @param {boolean=} unsigned Whether unsigned or not, defaults to `false` for signed
* @returns {!Long} The corresponding Long value
* @expose

@@ -119,8 +121,8 @@ */

cachedObj = INT_CACHE[value];
if (cachedObj) return cachedObj;
if (cachedObj)
return cachedObj;
}
obj = new Long(value, value < 0 ? -1 : 0, false);
if (-128 <= value && value < 128) {
if (-128 <= value && value < 128)
INT_CACHE[value] = obj;
}
return obj;

@@ -131,8 +133,8 @@ } else {

cachedObj = UINT_CACHE[value];
if (cachedObj) return cachedObj;
if (cachedObj)
return cachedObj;
}
obj = new Long(value, (value | 0) < 0 ? -1 : 0, true);
if (0 <= value && value < 256) {
if (0 <= value && value < 256)
UINT_CACHE[value] = obj;
}
return obj;

@@ -143,7 +145,6 @@ }

/**
* Returns a Long representing the given value, provided that it is a finite
* number. Otherwise, zero is returned.
* @param {number} value The number in question.
* @param {boolean=} unsigned Whether unsigned or not. Defaults to false (signed).
* @return {!Long} The corresponding Long value.
* Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned.
* @param {number} value The number in question
* @param {boolean=} unsigned Whether unsigned or not, defaults to `false` for signed
* @returns {!Long} The corresponding Long value
* @expose

@@ -153,24 +154,22 @@ */

unsigned = !!unsigned;
if (isNaN(value) || !isFinite(value)) {
if (isNaN(value) || !isFinite(value))
return Long.ZERO;
} else if (!unsigned && value <= -TWO_PWR_63_DBL) {
return Long.MIN_SIGNED_VALUE;
} else if (!unsigned && value + 1 >= TWO_PWR_63_DBL) {
return Long.MAX_SIGNED_VALUE;
} else if (unsigned && value >= TWO_PWR_64_DBL) {
if (!unsigned && value <= -TWO_PWR_63_DBL)
return Long.MIN_VALUE;
if (!unsigned && value + 1 >= TWO_PWR_63_DBL)
return Long.MAX_VALUE;
if (unsigned && value >= TWO_PWR_64_DBL)
return Long.MAX_UNSIGNED_VALUE;
} else if (value < 0) {
if (value < 0)
return Long.fromNumber(-value, unsigned).negate();
} else {
return new Long((value % TWO_PWR_32_DBL) | 0, (value / TWO_PWR_32_DBL) | 0, unsigned);
}
return new Long((value % TWO_PWR_32_DBL) | 0, (value / TWO_PWR_32_DBL) | 0, unsigned);
};
/**
* Returns a Long representing the 64bit integer that comes by concatenating the given low and high bits. Each is
* Returns a Long representing the 64 bit integer that comes by concatenating the given low and high bits. Each is
* assumed to use 32 bits.
* @param {number} lowBits The low 32 bits.
* @param {number} highBits The high 32 bits.
* @param {boolean=} unsigned Whether unsigned or not. Defaults to false (signed).
* @return {!Long} The corresponding Long value.
* @param {number} lowBits The low 32 bits
* @param {number} highBits The high 32 bits
* @param {boolean=} unsigned Whether unsigned or not, defaults to `false` for signed
* @returns {!Long} The corresponding Long value
* @expose

@@ -183,25 +182,9 @@ */

/**
* Returns a Long representing the 64bit integer that comes by concatenating the given low, middle and high bits.
* Each is assumed to use 28 bits.
* @param {number} part0 The low 28 bits
* @param {number} part1 The middle 28 bits
* @param {number} part2 The high 28 (8) bits
* @param {boolean=} unsigned Whether unsigned or not. Defaults to false (signed).
* @return {!Long}
* Returns a Long representation of the given string, written using the specified radix.
* @param {string} str The textual representation of the Long
* @param {(boolean|number)=} unsigned Whether unsigned or not, defaults to `false` for signed
* @param {number=} radix The radix in which the text is written (2-36), defaults to 10
* @returns {!Long} The corresponding Long value
* @expose
*/
Long.from28Bits = function(part0, part1, part2, unsigned) {
// 00000000000000000000000000001111 11111111111111111111111122222222 2222222222222
// LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
return Long.fromBits(part0 | (part1 << 28), (part1 >>> 4) | (part2) << 24, unsigned);
};
/**
* Returns a Long representation of the given string, written using the given radix.
* @param {string} str The textual representation of the Long.
* @param {(boolean|number)=} unsigned Whether unsigned or not. Defaults to false (signed).
* @param {number=} radix The radix in which the text is written.
* @return {!Long} The corresponding Long value.
* @expose
*/
Long.fromString = function(str, unsigned, radix) {

@@ -212,6 +195,5 @@ if (str.length === 0)

return Long.ZERO;
if (typeof unsigned === 'number') { // For goog.math.Long compatibility
radix = unsigned;
if (typeof unsigned === 'number') // For goog.math.long compatibility
radix = unsigned,
unsigned = false;
}
radix = radix || 10;

@@ -247,10 +229,25 @@ if (radix < 2 || 36 < radix)

/**
* Converts the specified value to a Long.
* @param {!Long|number|string|!{low: number, high: number, unsigned: boolean}} val Value
* @returns {!Long}
* @expose
*/
Long.valueOf = function(val) {
if (typeof val === 'number')
return Long.fromNumber(val);
if (typeof val === 'string')
return Long.fromString(val);
if (Long.isLong(val))
return val;
// Throws for not an object (undefined, null):
return Long(val.low, val.high, val.unsigned);
};
// NOTE: the compiler should inline these constant values below and then remove these variables, so there should be
// no runtime penalty for these.
// NOTE: The following constant values are used internally only and are therefore not exposed as properties of the
// Long class.
/**
* @type {number}
* @inner
*/

@@ -261,2 +258,3 @@ var TWO_PWR_16_DBL = 1 << 16;

* @type {number}
* @inner
*/

@@ -267,2 +265,3 @@ var TWO_PWR_24_DBL = 1 << 24;

* @type {number}
* @inner
*/

@@ -273,2 +272,3 @@ var TWO_PWR_32_DBL = TWO_PWR_16_DBL * TWO_PWR_16_DBL;

* @type {number}
* @inner
*/

@@ -279,2 +279,3 @@ var TWO_PWR_31_DBL = TWO_PWR_32_DBL / 2;

* @type {number}
* @inner
*/

@@ -285,2 +286,3 @@ var TWO_PWR_48_DBL = TWO_PWR_32_DBL * TWO_PWR_16_DBL;

* @type {number}
* @inner
*/

@@ -291,2 +293,3 @@ var TWO_PWR_64_DBL = TWO_PWR_32_DBL * TWO_PWR_32_DBL;

* @type {number}
* @inner
*/

@@ -297,2 +300,3 @@ var TWO_PWR_63_DBL = TWO_PWR_64_DBL / 2;

* @type {!Long}
* @inner
*/

@@ -302,2 +306,3 @@ var TWO_PWR_24 = Long.fromInt(1 << 24);

/**
* Signed zero.
* @type {!Long}

@@ -309,2 +314,3 @@ * @expose

/**
* Unsigned zero.
* @type {!Long}

@@ -316,2 +322,3 @@ * @expose

/**
* Signed one.
* @type {!Long}

@@ -323,2 +330,3 @@ * @expose

/**
* Unsigned one.
* @type {!Long}

@@ -330,2 +338,3 @@ * @expose

/**
* Signed negative one.
* @type {!Long}

@@ -337,43 +346,27 @@ * @expose

/**
* Maximum signed value.
* @type {!Long}
* @expose
*/
Long.MAX_SIGNED_VALUE = Long.fromBits(0xFFFFFFFF | 0, 0x7FFFFFFF | 0, false);
Long.MAX_VALUE = Long.fromBits(0xFFFFFFFF|0, 0x7FFFFFFF|0, false);
/**
* Maximum unsigned value.
* @type {!Long}
* @expose
*/
Long.MAX_UNSIGNED_VALUE = Long.fromBits(0xFFFFFFFF | 0, 0xFFFFFFFF | 0, true);
Long.MAX_UNSIGNED_VALUE = Long.fromBits(0xFFFFFFFF|0, 0xFFFFFFFF|0, true);
/**
* Alias of {@link Long.MAX_SIGNED_VALUE} for goog.math.Long compatibility.
* Minimum signed value.
* @type {!Long}
* @expose
*/
Long.MAX_VALUE = Long.MAX_SIGNED_VALUE;
Long.MIN_VALUE = Long.fromBits(0, 0x80000000|0, false);
/**
* @type {!Long}
* Converts the Long to a 32 bit integer, assuming it is a 32 bit integer.
* @returns {number}
* @expose
*/
Long.MIN_SIGNED_VALUE = Long.fromBits(0, 0x80000000 | 0, false);
/**
* @type {!Long}
* @expose
*/
Long.MIN_UNSIGNED_VALUE = Long.fromBits(0, 0, true);
/**
* Alias of {@link Long.MIN_SIGNED_VALUE} for goog.math.Long compatibility.
* @type {!Long}
* @expose
*/
Long.MIN_VALUE = Long.MIN_SIGNED_VALUE;
/**
* @return {number} The value, assuming it is a 32-bit integer.
* @expose
*/
Long.prototype.toInt = function() {

@@ -384,3 +377,4 @@ return this.unsigned ? this.low >>> 0 : this.low;

/**
* @return {number} The closest floating-point representation to this value.
* Converts the Long to a the nearest floating-point representation of this value (double, 53 bit mantissa).
* @returns {number}
* @expose

@@ -396,5 +390,7 @@ */

/**
* @param {number=} radix The radix in which the text should be written.
* @return {string} The textual representation of this value.
* Converts the Long to a string written in the specified radix.
* @param {number=} radix Radix (2-36), defaults to 10
* @returns {string}
* @override
* @throws {RangeError} If `radix` is out of range
* @expose

@@ -404,11 +400,9 @@ */

radix = radix || 10;
if (radix < 2 || 36 < radix) {
throw(new Error('radix out of range: ' + radix));
}
if (this.isZero()) {
if (radix < 2 || 36 < radix)
throw RangeError('radix out of range: ' + radix);
if (this.isZero())
return '0';
}
var rem;
if (this.isNegative()) { // Unsigned Longs are never negative
if (this.equals(Long.MIN_SIGNED_VALUE)) {
if (this.equals(Long.MIN_VALUE)) {
// We need to change the Long value before it can be negated, so we remove

@@ -420,5 +414,4 @@ // the bottom-most digit in this base and then recurse to do the rest.

return div.toString(radix) + rem.toInt().toString(radix);
} else {
} else
return '-' + this.negate().toString(radix);
}
}

@@ -432,12 +425,11 @@

while (true) {
var remDiv = rem.div(radixToPower);
var intval = rem.subtract(remDiv.multiply(radixToPower)).toInt() >>> 0;
var digits = intval.toString(radix);
var remDiv = rem.div(radixToPower),
intval = rem.subtract(remDiv.multiply(radixToPower)).toInt() >>> 0,
digits = intval.toString(radix);
rem = remDiv;
if (rem.isZero()) {
if (rem.isZero())
return digits + result;
} else {
while (digits.length < 6) {
else {
while (digits.length < 6)
digits = '0' + digits;
}
result = '' + digits + result;

@@ -449,3 +441,4 @@ }

/**
* @return {number} The high 32 bits as a signed value.
* Gets the high 32 bits as a signed integer.
* @returns {number} Signed high bits
* @expose

@@ -458,3 +451,4 @@ */

/**
* @return {number} The high 32 bits as an unsigned value.
* Gets the high 32 bits as an unsigned integer.
* @returns {number} Unsigned high bits
* @expose

@@ -467,3 +461,4 @@ */

/**
* @return {number} The low 32 bits as a signed value.
* Gets the low 32 bits as a signed integer.
* @returns {number} Signed low bits
* @expose

@@ -476,3 +471,4 @@ */

/**
* @return {number} The low 32 bits as an unsigned value.
* Gets the low 32 bits as an unsigned integer.
* @returns {number} Unsigned low bits
* @expose

@@ -485,34 +481,28 @@ */

/**
* @return {number} Returns the number of bits needed to represent the absolute
* value of this Long.
* Gets the number of bits needed to represent the absolute value of this Long.
* @returns {number}
* @expose
*/
Long.prototype.getNumBitsAbs = function() {
if (this.isNegative()) { // Unsigned Longs are never negative
if (this.equals(Long.MIN_SIGNED_VALUE)) {
return 64;
} else {
return this.negate().getNumBitsAbs();
}
} else {
var val = this.high != 0 ? this.high : this.low;
for (var bit = 31; bit > 0; bit--) {
if ((val & (1 << bit)) != 0) {
break;
}
}
return this.high != 0 ? bit + 33 : bit + 1;
}
if (this.isNegative()) // Unsigned Longs are never negative
return this.equals(Long.MIN_VALUE) ? 64 : this.negate().getNumBitsAbs();
var val = this.high != 0 ? this.high : this.low;
for (var bit = 31; bit > 0; bit--)
if ((val & (1 << bit)) != 0)
break;
return this.high != 0 ? bit + 33 : bit + 1;
};
/**
* @return {boolean} Whether this value is zero.
* Tests if this Long's value equals zero.
* @returns {boolean}
* @expose
*/
Long.prototype.isZero = function() {
return this.high == 0 && this.low == 0;
return this.high === 0 && this.low === 0;
};
/**
* @return {boolean} Whether this value is negative.
* Tests if this Long's value is negative.
* @returns {boolean}
* @expose

@@ -525,32 +515,50 @@ */

/**
* @return {boolean} Whether this value is odd.
* Tests if this Long's value is positive.
* @returns {boolean}
* @expose
*/
Long.prototype.isPositive = function() {
return this.unsigned || this.high >= 0;
};
/**
* Tests if this Long's value is odd.
* @returns {boolean}
* @expose
*/
Long.prototype.isOdd = function() {
return (this.low & 1) == 1;
return (this.low & 1) === 1;
};
/**
* @return {boolean} Whether this value is even.
* Tests if this Long's value is even.
* @returns {boolean}
*/
Long.prototype.isEven = function() {
return (this.low & 1) == 0;
return (this.low & 1) === 0;
};
/**
* @param {Long} other Long to compare against.
* @return {boolean} Whether this Long equals the other.
* Tests if this Long's value equals the specified's.
* @param {!Long|number|string} other Other value
* @returns {boolean}
* @expose
*/
Long.prototype.equals = function(other) {
if (this.unsigned != other.unsigned && (this.high >>> 31) != (other.high >>> 31)) return false;
return (this.high == other.high) && (this.low == other.low);
if (!Long.isLong(other))
other = Long.valueOf(other);
if (this.unsigned !== other.unsigned && (this.high >>> 31) !== (other.high >>> 31))
return false;
return this.high === other.high && this.low === other.low;
};
/**
* @param {Long} other Long to compare against.
* @return {boolean} Whether this Long does not equal the other.
* Tests if this Long's value differs from the specified's.
* @param {!Long|number|string} other Other value
* @returns {boolean}
* @expose
*/
Long.prototype.notEquals = function(other) {
if (!Long.isLong(other))
other = Long.valueOf(other);
return !this.equals(other);

@@ -560,7 +568,10 @@ };

/**
* @param {Long} other Long to compare against.
* @return {boolean} Whether this Long is less than the other.
* Tests if this Long's value is less than the specified's.
* @param {!Long|number|string} other Other value
* @returns {boolean}
* @expose
*/
Long.prototype.lessThan = function(other) {
if (!Long.isLong(other))
other = Long.valueOf(other);
return this.compare(other) < 0;

@@ -570,7 +581,10 @@ };

/**
* @param {Long} other Long to compare against.
* @return {boolean} Whether this Long is less than or equal to the other.
* Tests if this Long's value is less than or equal the specified's.
* @param {!Long|number|string} other Other value
* @returns {boolean}
* @expose
*/
Long.prototype.lessThanOrEqual = function(other) {
if (!Long.isLong(other))
other = Long.valueOf(other);
return this.compare(other) <= 0;

@@ -580,7 +594,10 @@ };

/**
* @param {Long} other Long to compare against.
* @return {boolean} Whether this Long is greater than the other.
* Tests if this Long's value is greater than the specified's.
* @param {!Long|number|string} other Other value
* @returns {boolean}
* @expose
*/
Long.prototype.greaterThan = function(other) {
if (!Long.isLong(other))
other = Long.valueOf(other);
return this.compare(other) > 0;

@@ -590,4 +607,5 @@ };

/**
* @param {Long} other Long to compare against.
* @return {boolean} Whether this Long is greater than or equal to the other.
* Tests if this Long's value is greater than or equal the specified's.
* @param {!Long|number|string} other Other value
* @returns {boolean}
* @expose

@@ -600,6 +618,6 @@ */

/**
* Compares this Long with the given one.
* @param {Long} other Long to compare against.
* @return {number} 0 if they are the same, 1 if the this is greater, and -1
* if the given one is greater.
* Compares this Long's value with the specified's.
* @param {!Long|number|string} other Other value
* @returns {number} 0 if they are the same, 1 if the this is greater and -1
* if the given one is greater
* @expose

@@ -615,19 +633,17 @@ */

if (!thisNeg && otherNeg) return 1;
if (!this.unsigned) {
// At this point the signs are the same
// At this point the sign bits are the same
if (!this.unsigned)
return this.subtract(other).isNegative() ? -1 : 1;
} else {
// Both are positive if at least one is unsigned
return (other.high >>> 0) > (this.high >>> 0) || (other.high == this.high && (other.low >>> 0) > (this.low >>> 0)) ? -1 : 1;
}
// Both are positive if at least one is unsigned
return (other.high >>> 0) > (this.high >>> 0) || (other.high === this.high && (other.low >>> 0) > (this.low >>> 0)) ? -1 : 1;
};
/**
* @return {!Long} The negation of this value.
* Negates this Long's value.
* @returns {!Long} Negated Long
* @expose
*/
Long.prototype.negate = function() {
if (!this.unsigned && this.equals(Long.MIN_SIGNED_VALUE)) {
return Long.MIN_SIGNED_VALUE;
}
if (!this.unsigned && this.equals(Long.MIN_VALUE))
return Long.MIN_VALUE;
return this.not().add(Long.ONE);

@@ -637,10 +653,13 @@ };

/**
* Returns the sum of this and the given Long.
* @param {Long} other Long to add to this one.
* @return {!Long} The sum of this and the given Long.
* Returns the sum of this and the specified Long.
* @param {!Long|number|string} addend Addend
* @returns {!Long} Sum
* @expose
*/
Long.prototype.add = function(other) {
Long.prototype.add = function(addend) {
if (!Long.isLong(addend))
addend = Long.valueOf(addend);
// Divide each number into 4 chunks of 16 bits, and then sum the chunks.
var a48 = this.high >>> 16;

@@ -651,6 +670,6 @@ var a32 = this.high & 0xFFFF;

var b48 = other.high >>> 16;
var b32 = other.high & 0xFFFF;
var b16 = other.low >>> 16;
var b00 = other.low & 0xFFFF;
var b48 = addend.high >>> 16;
var b32 = addend.high & 0xFFFF;
var b16 = addend.low >>> 16;
var b00 = addend.low & 0xFFFF;

@@ -673,48 +692,46 @@ var c48 = 0, c32 = 0, c16 = 0, c00 = 0;

/**
* Returns the difference of this and the given Long.
* @param {Long} other Long to subtract from this.
* @return {!Long} The difference of this and the given Long.
* Returns the difference of this and the specified Long.
* @param {!Long|number|string} subtrahend Subtrahend
* @returns {!Long} Difference
* @expose
*/
Long.prototype.subtract = function(other) {
return this.add(other.negate());
Long.prototype.subtract = function(subtrahend) {
if (!Long.isLong(subtrahend))
subtrahend = Long.valueOf(subtrahend);
return this.add(subtrahend.negate());
};
/**
* Returns the product of this and the given long.
* @param {Long} other Long to multiply with this.
* @return {!Long} The product of this and the other.
* Returns the product of this and the specified Long.
* @param {!Long|number|string} multiplier Multiplier
* @returns {!Long} Product
* @expose
*/
Long.prototype.multiply = function(other) {
if (this.isZero()) {
Long.prototype.multiply = function(multiplier) {
if (this.isZero())
return Long.ZERO;
} else if (other.isZero()) {
if (!Long.isLong(multiplier))
multiplier = Long.valueOf(multiplier);
if (multiplier.isZero())
return Long.ZERO;
}
if (this.equals(Long.MIN_VALUE)) {
return other.isOdd() ? Long.MIN_VALUE : Long.ZERO;
} else if (other.equals(Long.MIN_VALUE)) {
if (this.equals(Long.MIN_VALUE))
return multiplier.isOdd() ? Long.MIN_VALUE : Long.ZERO;
if (multiplier.equals(Long.MIN_VALUE))
return this.isOdd() ? Long.MIN_VALUE : Long.ZERO;
}
if (this.isNegative()) {
if (other.isNegative()) {
return this.negate().multiply(other.negate());
} else {
return this.negate().multiply(other).negate();
}
} else if (other.isNegative()) {
return this.multiply(other.negate()).negate();
}
if (multiplier.isNegative())
return this.negate().multiply(multiplier.negate());
else
return this.negate().multiply(multiplier).negate();
} else if (multiplier.isNegative())
return this.multiply(multiplier.negate()).negate();
// If both longs are small, use float multiplication
if (this.lessThan(TWO_PWR_24) &&
other.lessThan(TWO_PWR_24)) {
return Long.fromNumber(this.toNumber() * other.toNumber(), this.unsigned);
}
if (this.lessThan(TWO_PWR_24) && multiplier.lessThan(TWO_PWR_24))
return Long.fromNumber(this.toNumber() * multiplier.toNumber(), this.unsigned);
// Divide each long into 4 chunks of 16 bits, and then add up 4x4 products.
// We can skip products that would overflow.
var a48 = this.high >>> 16;

@@ -725,6 +742,6 @@ var a32 = this.high & 0xFFFF;

var b48 = other.high >>> 16;
var b32 = other.high & 0xFFFF;
var b16 = other.low >>> 16;
var b00 = other.low & 0xFFFF;
var b48 = multiplier.high >>> 16;
var b32 = multiplier.high & 0xFFFF;
var b16 = multiplier.low >>> 16;
var b00 = multiplier.low & 0xFFFF;

@@ -756,44 +773,41 @@ var c48 = 0, c32 = 0, c16 = 0, c00 = 0;

/**
* Returns this Long divided by the given one.
* @param {Long} other Long by which to divide.
* @return {!Long} This Long divided by the given one.
* Returns this Long divided by the specified.
* @param {!Long|number|string} divisor Divisor
* @returns {!Long} Quotient
* @expose
*/
Long.prototype.div = function(other) {
if (other.isZero()) {
Long.prototype.div = function(divisor) {
if (!Long.isLong(divisor))
divisor = Long.valueOf(divisor);
if (divisor.isZero())
throw(new Error('division by zero'));
} else if (this.isZero()) {
if (this.isZero())
return this.unsigned ? Long.UZERO : Long.ZERO;
}
var approx, rem, res;
if (this.equals(Long.MIN_SIGNED_VALUE)) {
if (other.equals(Long.ONE) || other.equals(Long.NEG_ONE)) {
return Long.MIN_SIGNED_VALUE; // recall that -MIN_VALUE == MIN_VALUE
} else if (other.equals(Long.MIN_SIGNED_VALUE)) {
if (this.equals(Long.MIN_VALUE)) {
if (divisor.equals(Long.ONE) || divisor.equals(Long.NEG_ONE))
return Long.MIN_VALUE; // recall that -MIN_VALUE == MIN_VALUE
else if (divisor.equals(Long.MIN_VALUE))
return Long.ONE;
} else {
else {
// At this point, we have |other| >= 2, so |this/other| < |MIN_VALUE|.
var halfThis = this.shiftRight(1);
approx = halfThis.div(other).shiftLeft(1);
approx = halfThis.div(divisor).shiftLeft(1);
if (approx.equals(Long.ZERO)) {
return other.isNegative() ? Long.ONE : Long.NEG_ONE;
return divisor.isNegative() ? Long.ONE : Long.NEG_ONE;
} else {
rem = this.subtract(other.multiply(approx));
res = approx.add(rem.div(other));
rem = this.subtract(divisor.multiply(approx));
res = approx.add(rem.div(divisor));
return res;
}
}
} else if (other.equals(Long.MIN_SIGNED_VALUE)) {
} else if (divisor.equals(Long.MIN_VALUE))
return this.unsigned ? Long.UZERO : Long.ZERO;
}
if (this.isNegative()) {
if (other.isNegative()) {
return this.negate().div(other.negate());
} else {
return this.negate().div(other).negate();
}
} else if (other.isNegative()) {
return this.div(other.negate()).negate();
}
if (divisor.isNegative())
return this.negate().div(divisor.negate());
return this.negate().div(divisor).negate();
} else if (divisor.isNegative())
return this.div(divisor.negate()).negate();
// Repeat the following until the remainder is less than other: find a

@@ -806,20 +820,20 @@ // floating-point that approximates remainder / other *from below*, add this

rem = this;
while (rem.greaterThanOrEqual(other)) {
while (rem.greaterThanOrEqual(divisor)) {
// Approximate the result of division. This may be a little greater or
// smaller than the actual value.
approx = Math.max(1, Math.floor(rem.toNumber() / other.toNumber()));
approx = Math.max(1, Math.floor(rem.toNumber() / divisor.toNumber()));
// We will tweak the approximate result by changing it in the 48-th digit or
// the smallest non-fractional digit, whichever is larger.
var log2 = Math.ceil(Math.log(approx) / Math.LN2);
var delta = (log2 <= 48) ? 1 : Math.pow(2, log2 - 48);
var log2 = Math.ceil(Math.log(approx) / Math.LN2),
delta = (log2 <= 48) ? 1 : Math.pow(2, log2 - 48),
// Decrease the approximation until it is smaller than the remainder. Note
// that if it is too large, the product overflows and is negative.
var approxRes = Long.fromNumber(approx);
var approxRem = approxRes.multiply(other);
approxRes = Long.fromNumber(approx),
approxRem = approxRes.multiply(divisor);
while (approxRem.isNegative() || approxRem.greaterThan(rem)) {
approx -= delta;
approxRes = Long.fromNumber(approx, this.unsigned);
approxRem = approxRes.multiply(other);
approxRem = approxRes.multiply(divisor);
}

@@ -829,5 +843,4 @@

// infinite recursion since we would make no progress.
if (approxRes.isZero()) {
if (approxRes.isZero())
approxRes = Long.ONE;
}

@@ -841,13 +854,16 @@ res = res.add(approxRes);

/**
* Returns this Long modulo the given one.
* @param {Long} other Long by which to mod.
* @return {!Long} This Long modulo the given one.
* Returns this Long modulo the specified.
* @param {!Long|number|string} divisor Divisor
* @returns {!Long} Remainder
* @expose
*/
Long.prototype.modulo = function(other) {
return this.subtract(this.div(other).multiply(other));
Long.prototype.modulo = function(divisor) {
if (!Long.isLong(divisor))
divisor = Long.valueOf(divisor);
return this.subtract(this.div(divisor).multiply(divisor));
};
/**
* @return {!Long} The bitwise-NOT of this value.
* Returns the bitwise NOT of this Long.
* @returns {!Long}
* @expose

@@ -860,8 +876,10 @@ */

/**
* Returns the bitwise-AND of this Long and the given one.
* @param {Long} other The Long with which to AND.
* @return {!Long} The bitwise-AND of this and the other.
* Returns the bitwise AND of this Long and the specified.
* @param {!Long|number|string} other Other Long
* @returns {!Long}
* @expose
*/
Long.prototype.and = function(other) {
if (!Long.isLong(other))
other = Long.valueOf(other);
return Long.fromBits(this.low & other.low, this.high & other.high, this.unsigned);

@@ -871,8 +889,10 @@ };

/**
* Returns the bitwise-OR of this Long and the given one.
* @param {Long} other The Long with which to OR.
* @return {!Long} The bitwise-OR of this and the other.
* Returns the bitwise OR of this Long and the specified.
* @param {!Long|number|string} other Other Long
* @returns {!Long}
* @expose
*/
Long.prototype.or = function(other) {
if (!Long.isLong(other))
other = Long.valueOf(other);
return Long.fromBits(this.low | other.low, this.high | other.high, this.unsigned);

@@ -882,8 +902,10 @@ };

/**
* Returns the bitwise-XOR of this Long and the given one.
* @param {Long} other The Long with which to XOR.
* @return {!Long} The bitwise-XOR of this and the other.
* Returns the bitwise XOR of this Long and the given one.
* @param {!Long|number|string} other Other Long
* @returns {!Long}
* @expose
*/
Long.prototype.xor = function(other) {
if (!Long.isLong(other))
other = Long.valueOf(other);
return Long.fromBits(this.low ^ other.low, this.high ^ other.high, this.unsigned);

@@ -894,7 +916,9 @@ };

* Returns this Long with bits shifted to the left by the given amount.
* @param {number} numBits The number of bits by which to shift.
* @return {!Long} This shifted to the left by the given amount.
* @param {number|!Long} numBits Number of bits
* @returns {!Long} Shifted Long
* @expose
*/
Long.prototype.shiftLeft = function(numBits) {
if (Long.isLong(numBits))
numBits = numBits.toInt();
if ((numBits &= 63) === 0)

@@ -909,8 +933,10 @@ return this;

/**
* Returns this Long with bits shifted to the right by the given amount.
* @param {number} numBits The number of bits by which to shift.
* @return {!Long} This shifted to the right by the given amount.
* Returns this Long with bits arithmetically shifted to the right by the given amount.
* @param {number|!Long} numBits Number of bits
* @returns {!Long} Shifted Long
* @expose
*/
Long.prototype.shiftRight = function(numBits) {
if (Long.isLong(numBits))
numBits = numBits.toInt();
if ((numBits &= 63) === 0)

@@ -925,14 +951,14 @@ return this;

/**
* Returns this Long with bits shifted to the right by the given amount, with
* the new top bits matching the current sign bit.
* @param {number} numBits The number of bits by which to shift.
* @return {!Long} This shifted to the right by the given amount, with
* zeros placed into the new leading bits.
* Returns this Long with bits logically shifted to the right by the given amount.
* @param {number|!Long} numBits Number of bits
* @returns {!Long} Shifted Long
* @expose
*/
Long.prototype.shiftRightUnsigned = function(numBits) {
if (Long.isLong(numBits))
numBits = numBits.toInt();
numBits &= 63;
if (numBits == 0) {
if (numBits === 0)
return this;
} else {
else {
var high = this.high;

@@ -942,7 +968,6 @@ if (numBits < 32) {

return Long.fromBits((low >>> numBits) | (high << (32 - numBits)), high >>> numBits, this.unsigned);
} else if (numBits == 32) {
} else if (numBits === 32)
return Long.fromBits(high, 0, this.unsigned);
} else {
else
return Long.fromBits(high >>> (numBits - 32), 0, this.unsigned);
}
}

@@ -952,41 +977,30 @@ };

/**
* @return {!Long} Signed long
* Converts this Long to signed.
* @returns {!Long} Signed long
* @expose
*/
Long.prototype.toSigned = function() {
var l = this.clone();
l.unsigned = false;
return l;
if (!this.unsigned)
return this;
return new Long(this.low, this.high, false);
};
/**
* @return {!Long} Unsigned long
* Converts this Long to unsigned.
* @returns {!Long} Unsigned long
* @expose
*/
Long.prototype.toUnsigned = function() {
var l = this.clone();
l.unsigned = true;
return l;
if (this.unsigned)
return this;
return new Long(this.low, this.high, true);
};
/**
* @return {Long} Cloned instance with the same low/high bits and unsigned flag.
* @expose
*/
Long.prototype.clone = function() {
return new Long(this.low, this.high, this.unsigned);
};
// Enable module loading if available
if (typeof module != 'undefined' && module["exports"]) { // CommonJS
/* CommonJS */ if (typeof module !== 'undefined' && module["exports"])
module["exports"] = Long;
} else if (typeof define != 'undefined' && define["amd"]) { // AMD
define("Math/Long", [], function() { return Long; });
} else { // Shim
if (!global["dcodeIO"]) {
global["dcodeIO"] = {};
}
global["dcodeIO"]["Long"] = Long;
}
/* AMD */ else if (typeof define === 'function' && define["amd"])
define(function() { return Long; });
/* Global */ else
(global["dcodeIO"] = global["dcodeIO"] || {})["Long"] = Long;
})(this);
(function(){/*
Long.js (c) 2013 Daniel Wirtz <dcode@dcode.io>
Released under the Apache License, Version 2.0
Derived from goog.math.Long from the Closure Library
see: https://github.com/dcodeIO/Long.js for details
*/
(function(q){function b(a,b,d){a&&"object"===typeof a&&(b=a.high,d=a.unsigned,a=a.low);this.low=a|0;this.high=b|0;this.unsigned=!!d}var r={},s={};b.fromInt=function(a,c){var d;if(c){a>>>=0;if(0<=a&&256>a&&(d=s[a]))return d;d=new b(a,0>(a|0)?-1:0,!0);0<=a&&256>a&&(s[a]=d)}else{a|=0;if(-128<=a&&128>a&&(d=r[a]))return d;d=new b(a,0>a?-1:0,!1);-128<=a&&128>a&&(r[a]=d)}return d};b.fromNumber=function(a,c){c=!!c;return isNaN(a)||!isFinite(a)?b.ZERO:!c&&a<=-t?b.MIN_SIGNED_VALUE:!c&&a+1>=t?b.MAX_SIGNED_VALUE:
c&&a>=u?b.MAX_UNSIGNED_VALUE:0>a?b.fromNumber(-a,c).negate():new b(a%l|0,a/l|0,c)};b.fromBits=function(a,c,d){return new b(a,c,d)};b.from28Bits=function(a,c,d,e){return b.fromBits(a|c<<28,c>>>4|d<<24,e)};b.fromString=function(a,c,d){if(0===a.length)throw Error("number format error: empty string");if("NaN"===a||"Infinity"===a||"+Infinity"===a||"-Infinity"===a)return b.ZERO;"number"===typeof c&&(d=c,c=!1);d=d||10;if(2>d||36<d)throw Error("radix out of range: "+d);var e;if(0<(e=a.indexOf("-")))throw Error('number format error: interior "-" character: '+
a);if(0===e)return b.fromString(a.substring(1),c,d).negate();e=b.fromNumber(Math.pow(d,8));for(var f=b.ZERO,g=0;g<a.length;g+=8){var k=Math.min(8,a.length-g),m=parseInt(a.substring(g,g+k),d);8>k?(k=b.fromNumber(Math.pow(d,k)),f=f.multiply(k).add(b.fromNumber(m))):(f=f.multiply(e),f=f.add(b.fromNumber(m)))}f.unsigned=c;return f};var l=4294967296,u=l*l,t=u/2,v=b.fromInt(16777216);b.ZERO=b.fromInt(0);b.UZERO=b.fromInt(0,!0);b.ONE=b.fromInt(1);b.UONE=b.fromInt(1,!0);b.NEG_ONE=b.fromInt(-1);b.MAX_SIGNED_VALUE=
b.fromBits(-1,2147483647,!1);b.MAX_UNSIGNED_VALUE=b.fromBits(-1,-1,!0);b.MAX_VALUE=b.MAX_SIGNED_VALUE;b.MIN_SIGNED_VALUE=b.fromBits(0,-2147483648,!1);b.MIN_UNSIGNED_VALUE=b.fromBits(0,0,!0);b.MIN_VALUE=b.MIN_SIGNED_VALUE;b.prototype.toInt=function(){return this.unsigned?this.low>>>0:this.low};b.prototype.toNumber=function(){return this.unsigned?(this.high>>>0)*l+(this.low>>>0):this.high*l+(this.low>>>0)};b.prototype.toString=function(a){a=a||10;if(2>a||36<a)throw Error("radix out of range: "+a);if(this.isZero())return"0";
var c;if(this.isNegative()){if(this.equals(b.MIN_SIGNED_VALUE)){c=b.fromNumber(a);var d=this.div(c);c=d.multiply(c).subtract(this);return d.toString(a)+c.toInt().toString(a)}return"-"+this.negate().toString(a)}d=b.fromNumber(Math.pow(a,6),this.unsigned);c=this;for(var e="";;){var f=c.div(d),g=(c.subtract(f.multiply(d)).toInt()>>>0).toString(a);c=f;if(c.isZero())return g+e;for(;6>g.length;)g="0"+g;e=""+g+e}};b.prototype.getHighBits=function(){return this.high};b.prototype.getHighBitsUnsigned=function(){return this.high>>>
0};b.prototype.getLowBits=function(){return this.low};b.prototype.getLowBitsUnsigned=function(){return this.low>>>0};b.prototype.getNumBitsAbs=function(){if(this.isNegative())return this.equals(b.MIN_SIGNED_VALUE)?64:this.negate().getNumBitsAbs();for(var a=0!=this.high?this.high:this.low,c=31;0<c&&0==(a&1<<c);c--);return 0!=this.high?c+33:c+1};b.prototype.isZero=function(){return 0==this.high&&0==this.low};b.prototype.isNegative=function(){return!this.unsigned&&0>this.high};b.prototype.isOdd=function(){return 1==
(this.low&1)};b.prototype.equals=function(a){return this.unsigned!=a.unsigned&&this.high>>>31!=a.high>>>31?!1:this.high==a.high&&this.low==a.low};b.prototype.notEquals=function(a){return!this.equals(a)};b.prototype.lessThan=function(a){return 0>this.compare(a)};b.prototype.lessThanOrEqual=function(a){return 0>=this.compare(a)};b.prototype.greaterThan=function(a){return 0<this.compare(a)};b.prototype.greaterThanOrEqual=function(a){return 0<=this.compare(a)};b.prototype.compare=function(a){if(this.equals(a))return 0;
var b=this.isNegative(),d=a.isNegative();return b&&!d?-1:!b&&d?1:this.unsigned?a.high>>>0>this.high>>>0||a.high==this.high&&a.low>>>0>this.low>>>0?-1:1:this.subtract(a).isNegative()?-1:1};b.prototype.negate=function(){return!this.unsigned&&this.equals(b.MIN_SIGNED_VALUE)?b.MIN_SIGNED_VALUE:this.not().add(b.ONE)};b.prototype.add=function(a){var c=this.high>>>16,d=this.high&65535,e=this.low>>>16,f=a.high>>>16,g=a.high&65535,k=a.low>>>16,m;m=0+((this.low&65535)+(a.low&65535));a=0+(m>>>16);a+=e+k;e=0+
(a>>>16);e+=d+g;d=0+(e>>>16);d=d+(c+f)&65535;return b.fromBits((a&65535)<<16|m&65535,d<<16|e&65535,this.unsigned)};b.prototype.subtract=function(a){return this.add(a.negate())};b.prototype.multiply=function(a){if(this.isZero()||a.isZero())return b.ZERO;if(this.equals(b.MIN_VALUE))return a.isOdd()?b.MIN_VALUE:b.ZERO;if(a.equals(b.MIN_VALUE))return this.isOdd()?b.MIN_VALUE:b.ZERO;if(this.isNegative())return a.isNegative()?this.negate().multiply(a.negate()):this.negate().multiply(a).negate();if(a.isNegative())return this.multiply(a.negate()).negate();
if(this.lessThan(v)&&a.lessThan(v))return b.fromNumber(this.toNumber()*a.toNumber(),this.unsigned);var c=this.high>>>16,d=this.high&65535,e=this.low>>>16,f=this.low&65535,g=a.high>>>16,k=a.high&65535,m=a.low>>>16;a=a.low&65535;var p,h,n,l;l=0+f*a;n=0+(l>>>16);n+=e*a;h=0+(n>>>16);n=(n&65535)+f*m;h+=n>>>16;n&=65535;h+=d*a;p=0+(h>>>16);h=(h&65535)+e*m;p+=h>>>16;h&=65535;h+=f*k;p+=h>>>16;h&=65535;p=p+(c*a+d*m+e*k+f*g)&65535;return b.fromBits(n<<16|l&65535,p<<16|h,this.unsigned)};b.prototype.div=function(a){if(a.isZero())throw Error("division by zero");
if(this.isZero())return this.unsigned?b.UZERO:b.ZERO;var c,d,e;if(this.equals(b.MIN_SIGNED_VALUE)){if(a.equals(b.ONE)||a.equals(b.NEG_ONE))return b.MIN_SIGNED_VALUE;if(a.equals(b.MIN_SIGNED_VALUE))return b.ONE;c=this.shiftRight(1).div(a).shiftLeft(1);if(c.equals(b.ZERO))return a.isNegative()?b.ONE:b.NEG_ONE;d=this.subtract(a.multiply(c));return e=c.add(d.div(a))}if(a.equals(b.MIN_SIGNED_VALUE))return this.unsigned?b.UZERO:b.ZERO;if(this.isNegative())return a.isNegative()?this.negate().div(a.negate()):
this.negate().div(a).negate();if(a.isNegative())return this.div(a.negate()).negate();e=b.ZERO;for(d=this;d.greaterThanOrEqual(a);){c=Math.max(1,Math.floor(d.toNumber()/a.toNumber()));for(var f=Math.ceil(Math.log(c)/Math.LN2),f=48>=f?1:Math.pow(2,f-48),g=b.fromNumber(c),k=g.multiply(a);k.isNegative()||k.greaterThan(d);)c-=f,g=b.fromNumber(c,this.unsigned),k=g.multiply(a);g.isZero()&&(g=b.ONE);e=e.add(g);d=d.subtract(k)}return e};b.prototype.modulo=function(a){return this.subtract(this.div(a).multiply(a))};
b.prototype.not=function(){return b.fromBits(~this.low,~this.high,this.unsigned)};b.prototype.and=function(a){return b.fromBits(this.low&a.low,this.high&a.high,this.unsigned)};b.prototype.or=function(a){return b.fromBits(this.low|a.low,this.high|a.high,this.unsigned)};b.prototype.xor=function(a){return b.fromBits(this.low^a.low,this.high^a.high,this.unsigned)};b.prototype.shiftLeft=function(a){return 0===(a&=63)?this:32>a?b.fromBits(this.low<<a,this.high<<a|this.low>>>32-a,this.unsigned):b.fromBits(0,
this.low<<a-32,this.unsigned)};b.prototype.shiftRight=function(a){return 0===(a&=63)?this:32>a?b.fromBits(this.low>>>a|this.high<<32-a,this.high>>a,this.unsigned):b.fromBits(this.high>>a-32,0<=this.high?0:-1,this.unsigned)};b.prototype.shiftRightUnsigned=function(a){a&=63;if(0==a)return this;var c=this.high;return 32>a?b.fromBits(this.low>>>a|c<<32-a,c>>>a,this.unsigned):32==a?b.fromBits(c,0,this.unsigned):b.fromBits(c>>>a-32,0,this.unsigned)};b.prototype.toSigned=function(){var a=this.clone();a.unsigned=
!1;return a};b.prototype.toUnsigned=function(){var a=this.clone();a.unsigned=!0;return a};b.prototype.clone=function(){return new b(this.low,this.high,this.unsigned)};"undefined"!=typeof module&&module.exports?module.exports=b:"undefined"!=typeof define&&define.amd?define("Math/Long",[],function(){return b}):(q.dcodeIO||(q.dcodeIO={}),q.dcodeIO.Long=b)})(this);})();
(function(q){function b(a,b,d){this.low=a|0;this.high=b|0;this.unsigned=!!d}b.isLong=function(a){return!0===(a&&a instanceof b)};var r={},s={};b.fromInt=function(a,c){var d;if(c){a>>>=0;if(0<=a&&256>a&&(d=s[a]))return d;d=new b(a,0>(a|0)?-1:0,!0);0<=a&&256>a&&(s[a]=d)}else{a|=0;if(-128<=a&&128>a&&(d=r[a]))return d;d=new b(a,0>a?-1:0,!1);-128<=a&&128>a&&(r[a]=d)}return d};b.fromNumber=function(a,c){c=!!c;return isNaN(a)||!isFinite(a)?b.ZERO:!c&&a<=-t?b.MIN_VALUE:!c&&a+1>=t?b.MAX_VALUE:c&&a>=u?b.MAX_UNSIGNED_VALUE:
0>a?b.fromNumber(-a,c).negate():new b(a%l|0,a/l|0,c)};b.fromBits=function(a,c,d){return new b(a,c,d)};b.fromString=function(a,c,d){if(0===a.length)throw Error("number format error: empty string");if("NaN"===a||"Infinity"===a||"+Infinity"===a||"-Infinity"===a)return b.ZERO;"number"===typeof c&&(d=c,c=!1);d=d||10;if(2>d||36<d)throw Error("radix out of range: "+d);var e;if(0<(e=a.indexOf("-")))throw Error('number format error: interior "-" character: '+a);if(0===e)return b.fromString(a.substring(1),
c,d).negate();e=b.fromNumber(Math.pow(d,8));for(var f=b.ZERO,g=0;g<a.length;g+=8){var k=Math.min(8,a.length-g),m=parseInt(a.substring(g,g+k),d);8>k?(k=b.fromNumber(Math.pow(d,k)),f=f.multiply(k).add(b.fromNumber(m))):(f=f.multiply(e),f=f.add(b.fromNumber(m)))}f.unsigned=c;return f};b.valueOf=function(a){return"number"===typeof a?b.fromNumber(a):"string"===typeof a?b.fromString(a):b.isLong(a)?a:b(a.low,a.high,a.unsigned)};var l=4294967296,u=l*l,t=u/2,v=b.fromInt(16777216);b.ZERO=b.fromInt(0);b.UZERO=
b.fromInt(0,!0);b.ONE=b.fromInt(1);b.UONE=b.fromInt(1,!0);b.NEG_ONE=b.fromInt(-1);b.MAX_VALUE=b.fromBits(-1,2147483647,!1);b.MAX_UNSIGNED_VALUE=b.fromBits(-1,-1,!0);b.MIN_VALUE=b.fromBits(0,-2147483648,!1);b.prototype.toInt=function(){return this.unsigned?this.low>>>0:this.low};b.prototype.toNumber=function(){return this.unsigned?(this.high>>>0)*l+(this.low>>>0):this.high*l+(this.low>>>0)};b.prototype.toString=function(a){a=a||10;if(2>a||36<a)throw RangeError("radix out of range: "+a);if(this.isZero())return"0";
var c;if(this.isNegative()){if(this.equals(b.MIN_VALUE)){c=b.fromNumber(a);var d=this.div(c);c=d.multiply(c).subtract(this);return d.toString(a)+c.toInt().toString(a)}return"-"+this.negate().toString(a)}d=b.fromNumber(Math.pow(a,6),this.unsigned);c=this;for(var e="";;){var f=c.div(d),g=(c.subtract(f.multiply(d)).toInt()>>>0).toString(a);c=f;if(c.isZero())return g+e;for(;6>g.length;)g="0"+g;e=""+g+e}};b.prototype.getHighBits=function(){return this.high};b.prototype.getHighBitsUnsigned=function(){return this.high>>>
0};b.prototype.getLowBits=function(){return this.low};b.prototype.getLowBitsUnsigned=function(){return this.low>>>0};b.prototype.getNumBitsAbs=function(){if(this.isNegative())return this.equals(b.MIN_VALUE)?64:this.negate().getNumBitsAbs();for(var a=0!=this.high?this.high:this.low,c=31;0<c&&0==(a&1<<c);c--);return 0!=this.high?c+33:c+1};b.prototype.isZero=function(){return 0===this.high&&0===this.low};b.prototype.isNegative=function(){return!this.unsigned&&0>this.high};b.prototype.isPositive=function(){return this.unsigned||
0<=this.high};b.prototype.isOdd=function(){return 1===(this.low&1)};b.prototype.equals=function(a){b.isLong(a)||(a=b.valueOf(a));return this.unsigned!==a.unsigned&&this.high>>>31!==a.high>>>31?!1:this.high===a.high&&this.low===a.low};b.prototype.notEquals=function(a){b.isLong(a)||(a=b.valueOf(a));return!this.equals(a)};b.prototype.lessThan=function(a){b.isLong(a)||(a=b.valueOf(a));return 0>this.compare(a)};b.prototype.lessThanOrEqual=function(a){b.isLong(a)||(a=b.valueOf(a));return 0>=this.compare(a)};
b.prototype.greaterThan=function(a){b.isLong(a)||(a=b.valueOf(a));return 0<this.compare(a)};b.prototype.greaterThanOrEqual=function(a){return 0<=this.compare(a)};b.prototype.compare=function(a){if(this.equals(a))return 0;var b=this.isNegative(),d=a.isNegative();return b&&!d?-1:!b&&d?1:this.unsigned?a.high>>>0>this.high>>>0||a.high===this.high&&a.low>>>0>this.low>>>0?-1:1:this.subtract(a).isNegative()?-1:1};b.prototype.negate=function(){return!this.unsigned&&this.equals(b.MIN_VALUE)?b.MIN_VALUE:this.not().add(b.ONE)};
b.prototype.add=function(a){b.isLong(a)||(a=b.valueOf(a));var c=this.high>>>16,d=this.high&65535,e=this.low>>>16,f=a.high>>>16,g=a.high&65535,k=a.low>>>16,m;m=0+((this.low&65535)+(a.low&65535));a=0+(m>>>16);a+=e+k;e=0+(a>>>16);e+=d+g;d=0+(e>>>16);d=d+(c+f)&65535;return b.fromBits((a&65535)<<16|m&65535,d<<16|e&65535,this.unsigned)};b.prototype.subtract=function(a){b.isLong(a)||(a=b.valueOf(a));return this.add(a.negate())};b.prototype.multiply=function(a){if(this.isZero())return b.ZERO;b.isLong(a)||
(a=b.valueOf(a));if(a.isZero())return b.ZERO;if(this.equals(b.MIN_VALUE))return a.isOdd()?b.MIN_VALUE:b.ZERO;if(a.equals(b.MIN_VALUE))return this.isOdd()?b.MIN_VALUE:b.ZERO;if(this.isNegative())return a.isNegative()?this.negate().multiply(a.negate()):this.negate().multiply(a).negate();if(a.isNegative())return this.multiply(a.negate()).negate();if(this.lessThan(v)&&a.lessThan(v))return b.fromNumber(this.toNumber()*a.toNumber(),this.unsigned);var c=this.high>>>16,d=this.high&65535,e=this.low>>>16,f=
this.low&65535,g=a.high>>>16,k=a.high&65535,m=a.low>>>16;a=a.low&65535;var p,h,n,l;l=0+f*a;n=0+(l>>>16);n+=e*a;h=0+(n>>>16);n=(n&65535)+f*m;h+=n>>>16;n&=65535;h+=d*a;p=0+(h>>>16);h=(h&65535)+e*m;p+=h>>>16;h&=65535;h+=f*k;p+=h>>>16;h&=65535;p=p+(c*a+d*m+e*k+f*g)&65535;return b.fromBits(n<<16|l&65535,p<<16|h,this.unsigned)};b.prototype.div=function(a){b.isLong(a)||(a=b.valueOf(a));if(a.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?b.UZERO:b.ZERO;var c,d,e;if(this.equals(b.MIN_VALUE)){if(a.equals(b.ONE)||
a.equals(b.NEG_ONE))return b.MIN_VALUE;if(a.equals(b.MIN_VALUE))return b.ONE;c=this.shiftRight(1).div(a).shiftLeft(1);if(c.equals(b.ZERO))return a.isNegative()?b.ONE:b.NEG_ONE;d=this.subtract(a.multiply(c));return e=c.add(d.div(a))}if(a.equals(b.MIN_VALUE))return this.unsigned?b.UZERO:b.ZERO;if(this.isNegative())return a.isNegative()?this.negate().div(a.negate()):this.negate().div(a).negate();if(a.isNegative())return this.div(a.negate()).negate();e=b.ZERO;for(d=this;d.greaterThanOrEqual(a);){c=Math.max(1,
Math.floor(d.toNumber()/a.toNumber()));for(var f=Math.ceil(Math.log(c)/Math.LN2),f=48>=f?1:Math.pow(2,f-48),g=b.fromNumber(c),k=g.multiply(a);k.isNegative()||k.greaterThan(d);)c-=f,g=b.fromNumber(c,this.unsigned),k=g.multiply(a);g.isZero()&&(g=b.ONE);e=e.add(g);d=d.subtract(k)}return e};b.prototype.modulo=function(a){b.isLong(a)||(a=b.valueOf(a));return this.subtract(this.div(a).multiply(a))};b.prototype.not=function(){return b.fromBits(~this.low,~this.high,this.unsigned)};b.prototype.and=function(a){b.isLong(a)||
(a=b.valueOf(a));return b.fromBits(this.low&a.low,this.high&a.high,this.unsigned)};b.prototype.or=function(a){b.isLong(a)||(a=b.valueOf(a));return b.fromBits(this.low|a.low,this.high|a.high,this.unsigned)};b.prototype.xor=function(a){b.isLong(a)||(a=b.valueOf(a));return b.fromBits(this.low^a.low,this.high^a.high,this.unsigned)};b.prototype.shiftLeft=function(a){b.isLong(a)&&(a=a.toInt());return 0===(a&=63)?this:32>a?b.fromBits(this.low<<a,this.high<<a|this.low>>>32-a,this.unsigned):b.fromBits(0,this.low<<
a-32,this.unsigned)};b.prototype.shiftRight=function(a){b.isLong(a)&&(a=a.toInt());return 0===(a&=63)?this:32>a?b.fromBits(this.low>>>a|this.high<<32-a,this.high>>a,this.unsigned):b.fromBits(this.high>>a-32,0<=this.high?0:-1,this.unsigned)};b.prototype.shiftRightUnsigned=function(a){b.isLong(a)&&(a=a.toInt());a&=63;if(0===a)return this;var c=this.high;return 32>a?b.fromBits(this.low>>>a|c<<32-a,c>>>a,this.unsigned):32===a?b.fromBits(c,0,this.unsigned):b.fromBits(c>>>a-32,0,this.unsigned)};b.prototype.toSigned=
function(){return this.unsigned?new b(this.low,this.high,!1):this};b.prototype.toUnsigned=function(){return this.unsigned?this:new b(this.low,this.high,!0)};"undefined"!==typeof module&&module.exports?module.exports=b:"function"===typeof define&&define.amd?define(function(){return b}):(q.dcodeIO=q.dcodeIO||{}).Long=b})(this);})();

@@ -38,2 +38,8 @@ /*

/**
* @param {*} obj
* @returns {boolean}
*/
Long.isLong = function(obj) {};
/**
* @param {number} value

@@ -61,11 +67,2 @@ * @param {boolean=} unsigned

/**
* @param {number} part0
* @param {number} part1
* @param {number} part2
* @param {boolean=} unsigned
* @return {!Long}
*/
Long.from28Bits = function(part0, part1, part2, unsigned) {};
/**
* @param {string} str

@@ -79,2 +76,8 @@ * @param {(boolean|number)=} unsigned

/**
* @param {!Long|number|string|!{low: number, high: number, unsigned: boolean}} val
* @return {!Long}
*/
Long.valueOf = function(val) {};
/**
* @type {!Long}

@@ -107,3 +110,3 @@ */

*/
Long.MAX_SIGNED_VALUE;
Long.MAX_VALUE;

@@ -113,3 +116,3 @@ /**

*/
Long.MIN_SIGNED_VALUE;
Long.MIN_VALUE;

@@ -122,17 +125,2 @@ /**

/**
* @type {!Long}
*/
Long.MIN_UNSIGNED_VALUE;
/**
* @type {!Long}
*/
Long.MAX_VALUE;
/**
* @type {!Long}
*/
Long.MIN_VALUE;
/**
* @type {number}

@@ -214,3 +202,3 @@ */

/**
* @param {Long} other
* @param {!Long|number|string} other
* @return {boolean}

@@ -221,3 +209,3 @@ */

/**
* @param {Long} other
* @param {!Long|number|string} other
* @return {boolean}

@@ -228,3 +216,3 @@ */

/**
* @param {Long} other
* @param {!Long|number|string} other
* @return {boolean}

@@ -235,3 +223,3 @@ */

/**
* @param {Long} other
* @param {!Long|number|string} other
* @return {boolean}

@@ -242,3 +230,3 @@ */

/**
* @param {Long} other
* @param {!Long|number|string} other
* @return {boolean}

@@ -249,3 +237,3 @@ */

/**
* @param {Long} other
* @param {!Long|number|string} other
* @return {boolean}

@@ -256,3 +244,3 @@ */

/**
* @param {Long} other
* @param {!Long|number|string} other
* @return {number}

@@ -268,3 +256,3 @@ */

/**
* @param {Long} other
* @param {!Long|number|string} other
* @return {!Long}

@@ -275,3 +263,3 @@ */

/**
* @param {Long} other
* @param {!Long|number|string} other
* @return {!Long}

@@ -282,3 +270,3 @@ */

/**
* @param {Long} other
* @param {!Long|number|string} other
* @return {!Long}

@@ -289,3 +277,3 @@ */

/**
* @param {Long} other
* @param {!Long|number|string} other
* @return {!Long}

@@ -296,3 +284,3 @@ */

/**
* @param {Long} other
* @param {!Long|number|string} other
* @return {!Long}

@@ -308,3 +296,3 @@ */

/**
* @param {Long} other
* @param {!Long|number|string} other
* @return {!Long}

@@ -315,3 +303,3 @@ */

/**
* @param {Long} other
* @param {!Long|number|string} other
* @return {!Long}

@@ -322,3 +310,3 @@ */

/**
* @param {Long} other
* @param {!Long|number|string} other
* @return {!Long}

@@ -329,3 +317,3 @@ */

/**
* @param {number} numBits
* @param {number|!Long} numBits
* @return {!Long}

@@ -336,3 +324,3 @@ */

/**
* @param {number} numBits
* @param {number|!Long} numBits
* @return {!Long}

@@ -343,3 +331,3 @@ */

/**
* @param {number} numBits
* @param {number|!Long} numBits
* @return {!Long}

@@ -358,6 +346,1 @@ */

Long.prototype.toUnsigned = function() {};
/**
* @return {!Long}
*/
Long.prototype.clone = function() {};
{
"name": "long",
"version": "1.2.3",
"version": "2.0.0",
"author": "Daniel Wirtz <dcode@dcode.io>",

@@ -15,5 +15,5 @@ "description": "A Long class for representing a 64-bit two's-complement integer value.",

"devDependencies": {
"intn": "~1",
"testjs": "latest",
"closurecompiler": "latest"
"closurecompiler": "latest",
"metascript": "~0"
},

@@ -25,7 +25,8 @@ "license": "Apache-2.0",

"scripts": {
"make": "cp src/Long.js dist/Long.js && npm run-script compile && npm test && npm run-script jsdoc",
"compile": "ccjs dist/Long.js --compilation_level=ADVANCED_OPTIMIZATIONS --output_wrapper=\"(function(){%output%})();\" > dist/Long.min.js",
"test": "node node_modules/testjs/bin/testjs tests/suite.js",
"jsdoc": "jsdoc -c jsdoc.json"
"build": "node scripts/build.js",
"make": "npm run-script build && npm run-script compile && npm run-script compress && npm test",
"compile": "ccjs dist/Long.js --compilation_level=ADVANCED_OPTIMIZATIONS --output_wrapper=\"(function(){%output%})();\" --create_source_map=dist/Long.min.map > dist/Long.min.js",
"compress": "gzip -c -9 dist/Long.min.js > dist/Long.min.js.gz",
"test": "node node_modules/testjs/bin/testjs tests/suite.js"
}
}

@@ -1,36 +0,33 @@

![Long.js - A Long class for representing a 64-bit two's-complement integer ](https://raw.github.com/dcodeIO/Long.js/master/long.png)
![Long.js - A Long class for representing a 64 bit two's-complement integer ](https://raw.github.com/dcodeIO/Long.js/master/Long.png)
=======
A Long class for representing a 64-bit two's-complement integer value derived from the [Closure Library](https://code.google.com/p/closure-library/)
A Long class for representing a 64 bit two's-complement integer value derived from the [Closure Library](https://code.google.com/p/closure-library/)
for stand-alone use and extended with unsigned support.
[![Build Status](https://travis-ci.org/dcodeIO/Long.js.svg)](https://travis-ci.org/dcodeIO/Long.js)
**Looking for arbitrary byte size integers?** Try [IntN.js](https://github.com/dcodeIO/IntN.js)!
[![Donate](https://raw.githubusercontent.com/dcodeIO/Long.js/master/donate.png)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=info%40code-emitter.com&item_name=Open%20Source%3A%20Long.js)
Why?
----
As of the [ECMAScript specification](http://ecma262-5.com/ELS5_HTML.htm#Section_8.5), number types have a maximum value
of 2^53. Beyond that, behaviour might be unexpected. Furthermore, bitwise operations can only be performed on 32bit
numbers. However, in some use cases it is required to be able to perform reliable mathematical and/or bitwise operations
on the full 64bits. This is where Long.js comes into play.
Background
----------
As of [ECMA-262 5th Edition](http://ecma262-5.com/ELS5_HTML.htm#Section_8.5), "all the positive and negative integers
whose magnitude is no greater than 2<sup>53</sup> are representable in the Number type", which is "representing the
doubleprecision 64-bit format IEEE 754 values as specified in the IEEE Standard for Binary Floating-Point Arithmetic".
The [maximum safe integer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)
in JavaScript is 2<sup>53</sup>-1.
Features
--------
* [CommonJS](http://www.commonjs.org/) compatible
* [RequireJS](http://requirejs.org/)/AMD compatible
* Shim compatible (include the script, then use var Long = dcodeIO.Long;)
* [node.js](http://nodejs.org) compatible, also available via [npm](https://npmjs.org/package/long)
* Fully documented using [jsdoc3](https://github.com/jsdoc3/jsdoc)
* API-compatible to the Closure Library implementation
* Zero production dependencies
* Small footprint
Example: 2<sup>64</sup>-1 is 18446744073709551615 but in JavaScript it evaluates to `18446744073709552000`.
Furthermore, bitwise operators in JavaScript "deal only with integers in the range −2<sup>31</sup> through
2<sup>31</sup>−1, inclusive, or in the range 0 through 2<sup>32</sup>−1, inclusive. These operators accept any value of
the Number type but first convert each such value to one of 2<sup>32</sup> integer values."
In some use cases, however, it is required to be able to reliably work with and perform bitwise operations on the full
64 bits. This is where Long.js comes into play.
Usage
-----
The class is compatible with CommonJS and AMD loaders and is exposed globally as `dcodeIO.Long` if neither is available.
#### node.js / CommonJS ####
Install: `npm install long`
```javascript
var Long = require("long");
var longVal = new Long(0xFFFFFFFF, 0x7FFFFFFF);

@@ -41,32 +38,469 @@ console.log(longVal.toString());

#### RequireJS / AMD ####
API
---
````javascript
require.config({
"paths": {
"Math/Long": "/path/to/Long.js"
}
});
require(["Math/Long"], function(Long) {
var longVal = new Long(0xFFFFFFFF, 0x7FFFFFFF);
console.log(longVal.toString());
});
````
#### new Long(low, high=, unsigned=)
### Browser / shim ####
Constructs a 64 bit two's-complement integer, given its low and high 32 bit values as *signed* integers.
See the from* functions below for more convenient ways of constructing Longs.
```html
<script src="Long.min.js"></script>
```
| Parameter | Type | Description
|-----------------|-----------------|---------------
| low | *number* | The low (signed) 32 bits of the long
| high | *number* | The high (signed) 32 bits of the long
| unsigned | *boolean* | Whether unsigned or not, defaults to `false` for signed
```javascript
var Long = dcodeIO.Long;
var longVal = new Long(0xFFFFFFFF, 0x7FFFFFFF);
alert(longVal.toString());
```
---
Documentation
-------------
* [View the API documentation](http://htmlpreview.github.io/?https://raw.githubusercontent.com/dcodeIO/Long.js/master/docs/Long.html)
#### Long.MAX_UNSIGNED_VALUE
Maximum unsigned value.
| | |
|-----------------|-----------------|
| **@type** | *!Long* |
#### Long.MAX_VALUE
Maximum signed value.
| | |
|-----------------|-----------------|
| **@type** | *!Long* |
#### Long.MIN_VALUE
Minimum signed value.
| | |
|-----------------|-----------------|
| **@type** | *!Long* |
#### Long.NEG_ONE
Signed negative one.
| | |
|-----------------|-----------------|
| **@type** | *!Long* |
#### Long.ONE
Signed one.
| | |
|-----------------|-----------------|
| **@type** | *!Long* |
#### Long.UONE
Unsigned one.
| | |
|-----------------|-----------------|
| **@type** | *!Long* |
#### Long.UZERO
Unsigned zero.
| | |
|-----------------|-----------------|
| **@type** | *!Long* |
#### Long.ZERO
Signed zero.
| | |
|-----------------|-----------------|
| **@type** | *!Long* |
#### Long.fromBits(lowBits, highBits, unsigned=)
Returns a Long representing the 64 bit integer that comes by concatenating the given low and high bits. Each is
assumed to use 32 bits.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| lowBits | *number* | The low 32 bits
| highBits | *number* | The high 32 bits
| unsigned | *boolean* | Whether unsigned or not, defaults to `false` for signed
| **@returns** | *!Long* | The corresponding Long value
#### Long.fromInt(value, unsigned=)
Returns a Long representing the given 32 bit integer value.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| value | *number* | The 32 bit integer in question
| unsigned | *boolean* | Whether unsigned or not, defaults to `false` for signed
| **@returns** | *!Long* | The corresponding Long value
#### Long.fromNumber(value, unsigned=)
Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| value | *number* | The number in question
| unsigned | *boolean* | Whether unsigned or not, defaults to `false` for signed
| **@returns** | *!Long* | The corresponding Long value
#### Long.fromString(str, unsigned=, radix=)
Returns a Long representation of the given string, written using the specified radix.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| str | *string* | The textual representation of the Long
| unsigned | *boolean &#124; number* | Whether unsigned or not, defaults to `false` for signed
| radix | *number* | The radix in which the text is written (2-36), defaults to 10
| **@returns** | *!Long* | The corresponding Long value
#### Long.isLong(obj)
Tests if the specified object is a Long.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| obj | *** | Object
| **@returns** | *boolean* |
#### Long.valueOf(val)
Converts the specified value to a Long.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| val | *!Long &#124; number &#124; string &#124; !{low: number, high: number, unsigned: boolean}* | Value
| **@returns** | *!Long* |
---
#### Long#high
The high 32 bits as a signed value.
| | |
|-----------------|-----------------|
| **@type** | *number* |
#### Long#low
The low 32 bits as a signed value.
| | |
|-----------------|-----------------|
| **@type** | *number* |
#### Long#unsigned
Whether unsigned or not.
| | |
|-----------------|-----------------|
| **@type** | *boolean* |
#### Long#add(addend)
Returns the sum of this and the specified Long.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| addend | *!Long &#124; number &#124; string* | Addend
| **@returns** | *!Long* | Sum
#### Long#and(other)
Returns the bitwise AND of this Long and the specified.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| other | *!Long &#124; number &#124; string* | Other Long
| **@returns** | *!Long* |
#### Long#compare(other)
Compares this Long's value with the specified's.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| other | *!Long &#124; number &#124; string* | Other value
| **@returns** | *number* | 0 if they are the same, 1 if the this is greater and -1 if the given one is greater
#### Long#div(divisor)
Returns this Long divided by the specified.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| divisor | *!Long &#124; number &#124; string* | Divisor
| **@returns** | *!Long* | Quotient
#### Long#equals(other)
Tests if this Long's value equals the specified's.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| other | *!Long &#124; number &#124; string* | Other value
| **@returns** | *boolean* |
#### Long#getHighBits()
Gets the high 32 bits as a signed integer.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| **@returns** | *number* | Signed high bits
#### Long#getHighBitsUnsigned()
Gets the high 32 bits as an unsigned integer.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| **@returns** | *number* | Unsigned high bits
#### Long#getLowBits()
Gets the low 32 bits as a signed integer.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| **@returns** | *number* | Signed low bits
#### Long#getLowBitsUnsigned()
Gets the low 32 bits as an unsigned integer.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| **@returns** | *number* | Unsigned low bits
#### Long#getNumBitsAbs()
Gets the number of bits needed to represent the absolute value of this Long.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| **@returns** | *number* |
#### Long#greaterThan(other)
Tests if this Long's value is greater than the specified's.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| other | *!Long &#124; number &#124; string* | Other value
| **@returns** | *boolean* |
#### Long#greaterThanOrEqual(other)
Tests if this Long's value is greater than or equal the specified's.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| other | *!Long &#124; number &#124; string* | Other value
| **@returns** | *boolean* |
#### Long#isEven()
Tests if this Long's value is even.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| **@returns** | *boolean* |
#### Long#isNegative()
Tests if this Long's value is negative.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| **@returns** | *boolean* |
#### Long#isOdd()
Tests if this Long's value is odd.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| **@returns** | *boolean* |
#### Long#isPositive()
Tests if this Long's value is positive.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| **@returns** | *boolean* |
#### Long#isZero()
Tests if this Long's value equals zero.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| **@returns** | *boolean* |
#### Long#lessThan(other)
Tests if this Long's value is less than the specified's.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| other | *!Long &#124; number &#124; string* | Other value
| **@returns** | *boolean* |
#### Long#lessThanOrEqual(other)
Tests if this Long's value is less than or equal the specified's.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| other | *!Long &#124; number &#124; string* | Other value
| **@returns** | *boolean* |
#### Long#modulo(divisor)
Returns this Long modulo the specified.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| divisor | *!Long &#124; number &#124; string* | Divisor
| **@returns** | *!Long* | Remainder
#### Long#multiply(multiplier)
Returns the product of this and the specified Long.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| multiplier | *!Long &#124; number &#124; string* | Multiplier
| **@returns** | *!Long* | Product
#### Long#negate()
Negates this Long's value.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| **@returns** | *!Long* | Negated Long
#### Long#not()
Returns the bitwise NOT of this Long.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| **@returns** | *!Long* |
#### Long#notEquals(other)
Tests if this Long's value differs from the specified's.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| other | *!Long &#124; number &#124; string* | Other value
| **@returns** | *boolean* |
#### Long#or(other)
Returns the bitwise OR of this Long and the specified.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| other | *!Long &#124; number &#124; string* | Other Long
| **@returns** | *!Long* |
#### Long#shiftLeft(numBits)
Returns this Long with bits shifted to the left by the given amount.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| numBits | *number &#124; !Long* | Number of bits
| **@returns** | *!Long* | Shifted Long
#### Long#shiftRight(numBits)
Returns this Long with bits arithmetically shifted to the right by the given amount.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| numBits | *number &#124; !Long* | Number of bits
| **@returns** | *!Long* | Shifted Long
#### Long#shiftRightUnsigned(numBits)
Returns this Long with bits logically shifted to the right by the given amount.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| numBits | *number &#124; !Long* | Number of bits
| **@returns** | *!Long* | Shifted Long
#### Long#subtract(subtrahend)
Returns the difference of this and the specified Long.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| subtrahend | *!Long &#124; number &#124; string* | Subtrahend
| **@returns** | *!Long* | Difference
#### Long#toInt()
Converts the Long to a 32 bit integer, assuming it is a 32 bit integer.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| **@returns** | *number* |
#### Long#toNumber()
Converts the Long to a the nearest floating-point representation of this value (double, 53 bit mantissa).
| Parameter | Type | Description
|-----------------|-----------------|---------------
| **@returns** | *number* |
#### Long#toSigned()
Converts this Long to signed.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| **@returns** | *!Long* | Signed long
#### Long#toString(radix=)
Converts the Long to a string written in the specified radix.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| radix | *number* | Radix (2-36), defaults to 10
| **@returns** | *string* |
| **@throws** | *RangeError* | If `radix` is out of range
#### Long#toUnsigned()
Converts this Long to unsigned.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| **@returns** | *!Long* | Unsigned long
#### Long#xor(other)
Returns the bitwise XOR of this Long and the given one.
| Parameter | Type | Description
|-----------------|-----------------|---------------
| other | *!Long &#124; number &#124; string* | Other Long
| **@returns** | *!Long* |
Downloads

@@ -73,0 +507,0 @@ ---------

@@ -17,6 +17,6 @@ /*

*/
/**
* @license Long.js (c) 2013 Daniel Wirtz <dcode@dcode.io>
* Released under the Apache License, Version 2.0
* Derived from goog.math.Long from the Closure Library
* see: https://github.com/dcodeIO/Long.js for details

@@ -28,34 +28,12 @@ */

/**
* Constructs a 64-bit two's-complement integer, given its low and high 32-bit
* values as *signed* integers. See the from* functions below for more
* convenient ways of constructing Longs.
*
* The internal representation of a long is the two given signed, 32-bit values.
* We use 32-bit pieces because these are the size of integers on which
* Javascript performs bit-operations. For operations like addition and
* multiplication, we split each number into 16-bit pieces, which can easily be
* multiplied within Javascript's floating-point representation without overflow
* or change in sign.
*
* In the algorithms below, we frequently reduce the negative case to the
* positive case by negating the input(s) and then post-processing the result.
* Note that we must ALWAYS check specially whether those values are MIN_VALUE
* (-2^63) because -MIN_VALUE == MIN_VALUE (since 2^63 cannot be represented as
* a positive number, it overflows back into a negative). Not handling this
* case would often result in infinite recursion.
*
* Constructs a 64 bit two's-complement integer, given its low and high 32 bit values as *signed* integers.
* See the from* functions below for more convenient ways of constructing Longs.
* @exports Long
* @class A Long class for representing a 64-bit two's-complement integer value.
* @param {number|!{low: number, high: number, unsigned: boolean}} low The low (signed) 32 bits of the long.
* Optionally accepts a Long-like object as the first parameter.
* @param {number=} high The high (signed) 32 bits of the long.
* @param {boolean=} unsigned Whether unsigned or not. Defaults to `false` (signed).
* @class A Long class for representing a 64 bit two's-complement integer value.
* @param {number} low The low (signed) 32 bits of the long
* @param {number} high The high (signed) 32 bits of the long
* @param {boolean=} unsigned Whether unsigned or not, defaults to `false` for signed
* @constructor
*/
var Long = function(low, high, unsigned) {
if (low && typeof low === 'object') {
high = low.high;
unsigned = low.unsigned;
low = low.low;
}

@@ -67,3 +45,3 @@ /**

*/
this.low = low | 0;
this.low = low|0;

@@ -75,3 +53,3 @@ /**

*/
this.high = high | 0;
this.high = high|0;

@@ -85,7 +63,29 @@ /**

};
// The internal representation of a long is the two given signed, 32-bit values.
// We use 32-bit pieces because these are the size of integers on which
// Javascript performs bit-operations. For operations like addition and
// multiplication, we split each number into 16 bit pieces, which can easily be
// multiplied within Javascript's floating-point representation without overflow
// or change in sign.
//
// In the algorithms below, we frequently reduce the negative case to the
// positive case by negating the input(s) and then post-processing the result.
// Note that we must ALWAYS check specially whether those values are MIN_VALUE
// (-2^63) because -MIN_VALUE == MIN_VALUE (since 2^63 cannot be represented as
// a positive number, it overflows back into a negative). Not handling this
// case would often result in infinite recursion.
//
// Common constant values ZERO, ONE, NEG_ONE, etc. are defined below the from*
// methods on which they depend.
// NOTE: Common constant values ZERO, ONE, NEG_ONE, etc. are defined below the from* methods on which they depend.
// NOTE: The following cache variables are used internally only and are therefore not exposed as properties of the
// Long class.
/**
* Tests if the specified object is a Long.
* @param {*} obj Object
* @returns {boolean}
* @expose
*/
Long.isLong = function(obj) {
return (obj && obj instanceof Long) === true;
};

@@ -95,2 +95,3 @@ /**

* @type {!Object}
* @inner
*/

@@ -102,2 +103,3 @@ var INT_CACHE = {};

* @type {!Object}
* @inner
*/

@@ -107,6 +109,6 @@ var UINT_CACHE = {};

/**
* Returns a Long representing the given (32-bit) integer value.
* @param {number} value The 32-bit integer in question.
* @param {boolean=} unsigned Whether unsigned or not. Defaults to false (signed).
* @return {!Long} The corresponding Long value.
* Returns a Long representing the given 32 bit integer value.
* @param {number} value The 32 bit integer in question
* @param {boolean=} unsigned Whether unsigned or not, defaults to `false` for signed
* @returns {!Long} The corresponding Long value
* @expose

@@ -120,8 +122,8 @@ */

cachedObj = INT_CACHE[value];
if (cachedObj) return cachedObj;
if (cachedObj)
return cachedObj;
}
obj = new Long(value, value < 0 ? -1 : 0, false);
if (-128 <= value && value < 128) {
if (-128 <= value && value < 128)
INT_CACHE[value] = obj;
}
return obj;

@@ -132,8 +134,8 @@ } else {

cachedObj = UINT_CACHE[value];
if (cachedObj) return cachedObj;
if (cachedObj)
return cachedObj;
}
obj = new Long(value, (value | 0) < 0 ? -1 : 0, true);
if (0 <= value && value < 256) {
if (0 <= value && value < 256)
UINT_CACHE[value] = obj;
}
return obj;

@@ -144,7 +146,6 @@ }

/**
* Returns a Long representing the given value, provided that it is a finite
* number. Otherwise, zero is returned.
* @param {number} value The number in question.
* @param {boolean=} unsigned Whether unsigned or not. Defaults to false (signed).
* @return {!Long} The corresponding Long value.
* Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned.
* @param {number} value The number in question
* @param {boolean=} unsigned Whether unsigned or not, defaults to `false` for signed
* @returns {!Long} The corresponding Long value
* @expose

@@ -154,24 +155,22 @@ */

unsigned = !!unsigned;
if (isNaN(value) || !isFinite(value)) {
if (isNaN(value) || !isFinite(value))
return Long.ZERO;
} else if (!unsigned && value <= -TWO_PWR_63_DBL) {
return Long.MIN_SIGNED_VALUE;
} else if (!unsigned && value + 1 >= TWO_PWR_63_DBL) {
return Long.MAX_SIGNED_VALUE;
} else if (unsigned && value >= TWO_PWR_64_DBL) {
if (!unsigned && value <= -TWO_PWR_63_DBL)
return Long.MIN_VALUE;
if (!unsigned && value + 1 >= TWO_PWR_63_DBL)
return Long.MAX_VALUE;
if (unsigned && value >= TWO_PWR_64_DBL)
return Long.MAX_UNSIGNED_VALUE;
} else if (value < 0) {
if (value < 0)
return Long.fromNumber(-value, unsigned).negate();
} else {
return new Long((value % TWO_PWR_32_DBL) | 0, (value / TWO_PWR_32_DBL) | 0, unsigned);
}
return new Long((value % TWO_PWR_32_DBL) | 0, (value / TWO_PWR_32_DBL) | 0, unsigned);
};
/**
* Returns a Long representing the 64bit integer that comes by concatenating the given low and high bits. Each is
* Returns a Long representing the 64 bit integer that comes by concatenating the given low and high bits. Each is
* assumed to use 32 bits.
* @param {number} lowBits The low 32 bits.
* @param {number} highBits The high 32 bits.
* @param {boolean=} unsigned Whether unsigned or not. Defaults to false (signed).
* @return {!Long} The corresponding Long value.
* @param {number} lowBits The low 32 bits
* @param {number} highBits The high 32 bits
* @param {boolean=} unsigned Whether unsigned or not, defaults to `false` for signed
* @returns {!Long} The corresponding Long value
* @expose

@@ -184,25 +183,9 @@ */

/**
* Returns a Long representing the 64bit integer that comes by concatenating the given low, middle and high bits.
* Each is assumed to use 28 bits.
* @param {number} part0 The low 28 bits
* @param {number} part1 The middle 28 bits
* @param {number} part2 The high 28 (8) bits
* @param {boolean=} unsigned Whether unsigned or not. Defaults to false (signed).
* @return {!Long}
* Returns a Long representation of the given string, written using the specified radix.
* @param {string} str The textual representation of the Long
* @param {(boolean|number)=} unsigned Whether unsigned or not, defaults to `false` for signed
* @param {number=} radix The radix in which the text is written (2-36), defaults to 10
* @returns {!Long} The corresponding Long value
* @expose
*/
Long.from28Bits = function(part0, part1, part2, unsigned) {
// 00000000000000000000000000001111 11111111111111111111111122222222 2222222222222
// LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
return Long.fromBits(part0 | (part1 << 28), (part1 >>> 4) | (part2) << 24, unsigned);
};
/**
* Returns a Long representation of the given string, written using the given radix.
* @param {string} str The textual representation of the Long.
* @param {(boolean|number)=} unsigned Whether unsigned or not. Defaults to false (signed).
* @param {number=} radix The radix in which the text is written.
* @return {!Long} The corresponding Long value.
* @expose
*/
Long.fromString = function(str, unsigned, radix) {

@@ -213,10 +196,9 @@ if (str.length === 0)

return Long.ZERO;
if (typeof unsigned === 'number') { // For goog.math.Long compatibility
radix = unsigned;
if (typeof unsigned === 'number') // For goog.math.long compatibility
radix = unsigned,
unsigned = false;
}
radix = radix || 10;
if (radix < 2 || 36 < radix)
throw Error('radix out of range: ' + radix);
var p;

@@ -248,10 +230,25 @@ if ((p = str.indexOf('-')) > 0)

/**
* Converts the specified value to a Long.
* @param {!Long|number|string|!{low: number, high: number, unsigned: boolean}} val Value
* @returns {!Long}
* @expose
*/
Long.valueOf = function(val) {
if (typeof val === 'number')
return Long.fromNumber(val);
if (typeof val === 'string')
return Long.fromString(val);
if (Long.isLong(val))
return val;
// Throws for not an object (undefined, null):
return Long(val.low, val.high, val.unsigned);
};
// NOTE: the compiler should inline these constant values below and then remove these variables, so there should be
// no runtime penalty for these.
// NOTE: The following constant values are used internally only and are therefore not exposed as properties of the
// Long class.
/**
* @type {number}
* @inner
*/

@@ -262,2 +259,3 @@ var TWO_PWR_16_DBL = 1 << 16;

* @type {number}
* @inner
*/

@@ -268,2 +266,3 @@ var TWO_PWR_24_DBL = 1 << 24;

* @type {number}
* @inner
*/

@@ -274,2 +273,3 @@ var TWO_PWR_32_DBL = TWO_PWR_16_DBL * TWO_PWR_16_DBL;

* @type {number}
* @inner
*/

@@ -280,2 +280,3 @@ var TWO_PWR_31_DBL = TWO_PWR_32_DBL / 2;

* @type {number}
* @inner
*/

@@ -286,2 +287,3 @@ var TWO_PWR_48_DBL = TWO_PWR_32_DBL * TWO_PWR_16_DBL;

* @type {number}
* @inner
*/

@@ -292,2 +294,3 @@ var TWO_PWR_64_DBL = TWO_PWR_32_DBL * TWO_PWR_32_DBL;

* @type {number}
* @inner
*/

@@ -298,2 +301,3 @@ var TWO_PWR_63_DBL = TWO_PWR_64_DBL / 2;

* @type {!Long}
* @inner
*/

@@ -303,2 +307,3 @@ var TWO_PWR_24 = Long.fromInt(1 << 24);

/**
* Signed zero.
* @type {!Long}

@@ -310,2 +315,3 @@ * @expose

/**
* Unsigned zero.
* @type {!Long}

@@ -317,2 +323,3 @@ * @expose

/**
* Signed one.
* @type {!Long}

@@ -324,2 +331,3 @@ * @expose

/**
* Unsigned one.
* @type {!Long}

@@ -331,2 +339,3 @@ * @expose

/**
* Signed negative one.
* @type {!Long}

@@ -338,43 +347,27 @@ * @expose

/**
* Maximum signed value.
* @type {!Long}
* @expose
*/
Long.MAX_SIGNED_VALUE = Long.fromBits(0xFFFFFFFF | 0, 0x7FFFFFFF | 0, false);
Long.MAX_VALUE = Long.fromBits(0xFFFFFFFF|0, 0x7FFFFFFF|0, false);
/**
* Maximum unsigned value.
* @type {!Long}
* @expose
*/
Long.MAX_UNSIGNED_VALUE = Long.fromBits(0xFFFFFFFF | 0, 0xFFFFFFFF | 0, true);
Long.MAX_UNSIGNED_VALUE = Long.fromBits(0xFFFFFFFF|0, 0xFFFFFFFF|0, true);
/**
* Alias of {@link Long.MAX_SIGNED_VALUE} for goog.math.Long compatibility.
* Minimum signed value.
* @type {!Long}
* @expose
*/
Long.MAX_VALUE = Long.MAX_SIGNED_VALUE;
Long.MIN_VALUE = Long.fromBits(0, 0x80000000|0, false);
/**
* @type {!Long}
* Converts the Long to a 32 bit integer, assuming it is a 32 bit integer.
* @returns {number}
* @expose
*/
Long.MIN_SIGNED_VALUE = Long.fromBits(0, 0x80000000 | 0, false);
/**
* @type {!Long}
* @expose
*/
Long.MIN_UNSIGNED_VALUE = Long.fromBits(0, 0, true);
/**
* Alias of {@link Long.MIN_SIGNED_VALUE} for goog.math.Long compatibility.
* @type {!Long}
* @expose
*/
Long.MIN_VALUE = Long.MIN_SIGNED_VALUE;
/**
* @return {number} The value, assuming it is a 32-bit integer.
* @expose
*/
Long.prototype.toInt = function() {

@@ -385,3 +378,4 @@ return this.unsigned ? this.low >>> 0 : this.low;

/**
* @return {number} The closest floating-point representation to this value.
* Converts the Long to a the nearest floating-point representation of this value (double, 53 bit mantissa).
* @returns {number}
* @expose

@@ -397,5 +391,7 @@ */

/**
* @param {number=} radix The radix in which the text should be written.
* @return {string} The textual representation of this value.
* Converts the Long to a string written in the specified radix.
* @param {number=} radix Radix (2-36), defaults to 10
* @returns {string}
* @override
* @throws {RangeError} If `radix` is out of range
* @expose

@@ -405,11 +401,9 @@ */

radix = radix || 10;
if (radix < 2 || 36 < radix) {
throw(new Error('radix out of range: ' + radix));
}
if (this.isZero()) {
if (radix < 2 || 36 < radix)
throw RangeError('radix out of range: ' + radix);
if (this.isZero())
return '0';
}
var rem;
if (this.isNegative()) { // Unsigned Longs are never negative
if (this.equals(Long.MIN_SIGNED_VALUE)) {
if (this.equals(Long.MIN_VALUE)) {
// We need to change the Long value before it can be negated, so we remove

@@ -421,5 +415,4 @@ // the bottom-most digit in this base and then recurse to do the rest.

return div.toString(radix) + rem.toInt().toString(radix);
} else {
} else
return '-' + this.negate().toString(radix);
}
}

@@ -433,12 +426,11 @@

while (true) {
var remDiv = rem.div(radixToPower);
var intval = rem.subtract(remDiv.multiply(radixToPower)).toInt() >>> 0;
var digits = intval.toString(radix);
var remDiv = rem.div(radixToPower),
intval = rem.subtract(remDiv.multiply(radixToPower)).toInt() >>> 0,
digits = intval.toString(radix);
rem = remDiv;
if (rem.isZero()) {
if (rem.isZero())
return digits + result;
} else {
while (digits.length < 6) {
else {
while (digits.length < 6)
digits = '0' + digits;
}
result = '' + digits + result;

@@ -450,3 +442,4 @@ }

/**
* @return {number} The high 32 bits as a signed value.
* Gets the high 32 bits as a signed integer.
* @returns {number} Signed high bits
* @expose

@@ -459,3 +452,4 @@ */

/**
* @return {number} The high 32 bits as an unsigned value.
* Gets the high 32 bits as an unsigned integer.
* @returns {number} Unsigned high bits
* @expose

@@ -468,3 +462,4 @@ */

/**
* @return {number} The low 32 bits as a signed value.
* Gets the low 32 bits as a signed integer.
* @returns {number} Signed low bits
* @expose

@@ -477,3 +472,4 @@ */

/**
* @return {number} The low 32 bits as an unsigned value.
* Gets the low 32 bits as an unsigned integer.
* @returns {number} Unsigned low bits
* @expose

@@ -486,34 +482,28 @@ */

/**
* @return {number} Returns the number of bits needed to represent the absolute
* value of this Long.
* Gets the number of bits needed to represent the absolute value of this Long.
* @returns {number}
* @expose
*/
Long.prototype.getNumBitsAbs = function() {
if (this.isNegative()) { // Unsigned Longs are never negative
if (this.equals(Long.MIN_SIGNED_VALUE)) {
return 64;
} else {
return this.negate().getNumBitsAbs();
}
} else {
var val = this.high != 0 ? this.high : this.low;
for (var bit = 31; bit > 0; bit--) {
if ((val & (1 << bit)) != 0) {
break;
}
}
return this.high != 0 ? bit + 33 : bit + 1;
}
if (this.isNegative()) // Unsigned Longs are never negative
return this.equals(Long.MIN_VALUE) ? 64 : this.negate().getNumBitsAbs();
var val = this.high != 0 ? this.high : this.low;
for (var bit = 31; bit > 0; bit--)
if ((val & (1 << bit)) != 0)
break;
return this.high != 0 ? bit + 33 : bit + 1;
};
/**
* @return {boolean} Whether this value is zero.
* Tests if this Long's value equals zero.
* @returns {boolean}
* @expose
*/
Long.prototype.isZero = function() {
return this.high == 0 && this.low == 0;
return this.high === 0 && this.low === 0;
};
/**
* @return {boolean} Whether this value is negative.
* Tests if this Long's value is negative.
* @returns {boolean}
* @expose

@@ -526,32 +516,50 @@ */

/**
* @return {boolean} Whether this value is odd.
* Tests if this Long's value is positive.
* @returns {boolean}
* @expose
*/
Long.prototype.isPositive = function() {
return this.unsigned || this.high >= 0;
};
/**
* Tests if this Long's value is odd.
* @returns {boolean}
* @expose
*/
Long.prototype.isOdd = function() {
return (this.low & 1) == 1;
return (this.low & 1) === 1;
};
/**
* @return {boolean} Whether this value is even.
* Tests if this Long's value is even.
* @returns {boolean}
*/
Long.prototype.isEven = function() {
return (this.low & 1) == 0;
return (this.low & 1) === 0;
};
/**
* @param {Long} other Long to compare against.
* @return {boolean} Whether this Long equals the other.
* Tests if this Long's value equals the specified's.
* @param {!Long|number|string} other Other value
* @returns {boolean}
* @expose
*/
Long.prototype.equals = function(other) {
if (this.unsigned != other.unsigned && (this.high >>> 31) != (other.high >>> 31)) return false;
return (this.high == other.high) && (this.low == other.low);
if (!Long.isLong(other))
other = Long.valueOf(other);
if (this.unsigned !== other.unsigned && (this.high >>> 31) !== (other.high >>> 31))
return false;
return this.high === other.high && this.low === other.low;
};
/**
* @param {Long} other Long to compare against.
* @return {boolean} Whether this Long does not equal the other.
* Tests if this Long's value differs from the specified's.
* @param {!Long|number|string} other Other value
* @returns {boolean}
* @expose
*/
Long.prototype.notEquals = function(other) {
if (!Long.isLong(other))
other = Long.valueOf(other);
return !this.equals(other);

@@ -561,7 +569,10 @@ };

/**
* @param {Long} other Long to compare against.
* @return {boolean} Whether this Long is less than the other.
* Tests if this Long's value is less than the specified's.
* @param {!Long|number|string} other Other value
* @returns {boolean}
* @expose
*/
Long.prototype.lessThan = function(other) {
if (!Long.isLong(other))
other = Long.valueOf(other);
return this.compare(other) < 0;

@@ -571,7 +582,10 @@ };

/**
* @param {Long} other Long to compare against.
* @return {boolean} Whether this Long is less than or equal to the other.
* Tests if this Long's value is less than or equal the specified's.
* @param {!Long|number|string} other Other value
* @returns {boolean}
* @expose
*/
Long.prototype.lessThanOrEqual = function(other) {
if (!Long.isLong(other))
other = Long.valueOf(other);
return this.compare(other) <= 0;

@@ -581,7 +595,10 @@ };

/**
* @param {Long} other Long to compare against.
* @return {boolean} Whether this Long is greater than the other.
* Tests if this Long's value is greater than the specified's.
* @param {!Long|number|string} other Other value
* @returns {boolean}
* @expose
*/
Long.prototype.greaterThan = function(other) {
if (!Long.isLong(other))
other = Long.valueOf(other);
return this.compare(other) > 0;

@@ -591,4 +608,5 @@ };

/**
* @param {Long} other Long to compare against.
* @return {boolean} Whether this Long is greater than or equal to the other.
* Tests if this Long's value is greater than or equal the specified's.
* @param {!Long|number|string} other Other value
* @returns {boolean}
* @expose

@@ -601,6 +619,6 @@ */

/**
* Compares this Long with the given one.
* @param {Long} other Long to compare against.
* @return {number} 0 if they are the same, 1 if the this is greater, and -1
* if the given one is greater.
* Compares this Long's value with the specified's.
* @param {!Long|number|string} other Other value
* @returns {number} 0 if they are the same, 1 if the this is greater and -1
* if the given one is greater
* @expose

@@ -616,19 +634,17 @@ */

if (!thisNeg && otherNeg) return 1;
if (!this.unsigned) {
// At this point the signs are the same
// At this point the sign bits are the same
if (!this.unsigned)
return this.subtract(other).isNegative() ? -1 : 1;
} else {
// Both are positive if at least one is unsigned
return (other.high >>> 0) > (this.high >>> 0) || (other.high == this.high && (other.low >>> 0) > (this.low >>> 0)) ? -1 : 1;
}
// Both are positive if at least one is unsigned
return (other.high >>> 0) > (this.high >>> 0) || (other.high === this.high && (other.low >>> 0) > (this.low >>> 0)) ? -1 : 1;
};
/**
* @return {!Long} The negation of this value.
* Negates this Long's value.
* @returns {!Long} Negated Long
* @expose
*/
Long.prototype.negate = function() {
if (!this.unsigned && this.equals(Long.MIN_SIGNED_VALUE)) {
return Long.MIN_SIGNED_VALUE;
}
if (!this.unsigned && this.equals(Long.MIN_VALUE))
return Long.MIN_VALUE;
return this.not().add(Long.ONE);

@@ -638,8 +654,11 @@ };

/**
* Returns the sum of this and the given Long.
* @param {Long} other Long to add to this one.
* @return {!Long} The sum of this and the given Long.
* Returns the sum of this and the specified Long.
* @param {!Long|number|string} addend Addend
* @returns {!Long} Sum
* @expose
*/
Long.prototype.add = function(other) {
Long.prototype.add = function(addend) {
if (!Long.isLong(addend))
addend = Long.valueOf(addend);
// Divide each number into 4 chunks of 16 bits, and then sum the chunks.

@@ -652,6 +671,6 @@

var b48 = other.high >>> 16;
var b32 = other.high & 0xFFFF;
var b16 = other.low >>> 16;
var b00 = other.low & 0xFFFF;
var b48 = addend.high >>> 16;
var b32 = addend.high & 0xFFFF;
var b16 = addend.low >>> 16;
var b00 = addend.low & 0xFFFF;

@@ -674,44 +693,42 @@ var c48 = 0, c32 = 0, c16 = 0, c00 = 0;

/**
* Returns the difference of this and the given Long.
* @param {Long} other Long to subtract from this.
* @return {!Long} The difference of this and the given Long.
* Returns the difference of this and the specified Long.
* @param {!Long|number|string} subtrahend Subtrahend
* @returns {!Long} Difference
* @expose
*/
Long.prototype.subtract = function(other) {
return this.add(other.negate());
Long.prototype.subtract = function(subtrahend) {
if (!Long.isLong(subtrahend))
subtrahend = Long.valueOf(subtrahend);
return this.add(subtrahend.negate());
};
/**
* Returns the product of this and the given long.
* @param {Long} other Long to multiply with this.
* @return {!Long} The product of this and the other.
* Returns the product of this and the specified Long.
* @param {!Long|number|string} multiplier Multiplier
* @returns {!Long} Product
* @expose
*/
Long.prototype.multiply = function(other) {
if (this.isZero()) {
Long.prototype.multiply = function(multiplier) {
if (this.isZero())
return Long.ZERO;
} else if (other.isZero()) {
if (!Long.isLong(multiplier))
multiplier = Long.valueOf(multiplier);
if (multiplier.isZero())
return Long.ZERO;
}
if (this.equals(Long.MIN_VALUE)) {
return other.isOdd() ? Long.MIN_VALUE : Long.ZERO;
} else if (other.equals(Long.MIN_VALUE)) {
if (this.equals(Long.MIN_VALUE))
return multiplier.isOdd() ? Long.MIN_VALUE : Long.ZERO;
if (multiplier.equals(Long.MIN_VALUE))
return this.isOdd() ? Long.MIN_VALUE : Long.ZERO;
}
if (this.isNegative()) {
if (other.isNegative()) {
return this.negate().multiply(other.negate());
} else {
return this.negate().multiply(other).negate();
}
} else if (other.isNegative()) {
return this.multiply(other.negate()).negate();
}
if (multiplier.isNegative())
return this.negate().multiply(multiplier.negate());
else
return this.negate().multiply(multiplier).negate();
} else if (multiplier.isNegative())
return this.multiply(multiplier.negate()).negate();
// If both longs are small, use float multiplication
if (this.lessThan(TWO_PWR_24) &&
other.lessThan(TWO_PWR_24)) {
return Long.fromNumber(this.toNumber() * other.toNumber(), this.unsigned);
}
if (this.lessThan(TWO_PWR_24) && multiplier.lessThan(TWO_PWR_24))
return Long.fromNumber(this.toNumber() * multiplier.toNumber(), this.unsigned);

@@ -726,6 +743,6 @@ // Divide each long into 4 chunks of 16 bits, and then add up 4x4 products.

var b48 = other.high >>> 16;
var b32 = other.high & 0xFFFF;
var b16 = other.low >>> 16;
var b00 = other.low & 0xFFFF;
var b48 = multiplier.high >>> 16;
var b32 = multiplier.high & 0xFFFF;
var b16 = multiplier.low >>> 16;
var b00 = multiplier.low & 0xFFFF;

@@ -757,43 +774,40 @@ var c48 = 0, c32 = 0, c16 = 0, c00 = 0;

/**
* Returns this Long divided by the given one.
* @param {Long} other Long by which to divide.
* @return {!Long} This Long divided by the given one.
* Returns this Long divided by the specified.
* @param {!Long|number|string} divisor Divisor
* @returns {!Long} Quotient
* @expose
*/
Long.prototype.div = function(other) {
if (other.isZero()) {
Long.prototype.div = function(divisor) {
if (!Long.isLong(divisor))
divisor = Long.valueOf(divisor);
if (divisor.isZero())
throw(new Error('division by zero'));
} else if (this.isZero()) {
if (this.isZero())
return this.unsigned ? Long.UZERO : Long.ZERO;
}
var approx, rem, res;
if (this.equals(Long.MIN_SIGNED_VALUE)) {
if (other.equals(Long.ONE) || other.equals(Long.NEG_ONE)) {
return Long.MIN_SIGNED_VALUE; // recall that -MIN_VALUE == MIN_VALUE
} else if (other.equals(Long.MIN_SIGNED_VALUE)) {
if (this.equals(Long.MIN_VALUE)) {
if (divisor.equals(Long.ONE) || divisor.equals(Long.NEG_ONE))
return Long.MIN_VALUE; // recall that -MIN_VALUE == MIN_VALUE
else if (divisor.equals(Long.MIN_VALUE))
return Long.ONE;
} else {
else {
// At this point, we have |other| >= 2, so |this/other| < |MIN_VALUE|.
var halfThis = this.shiftRight(1);
approx = halfThis.div(other).shiftLeft(1);
approx = halfThis.div(divisor).shiftLeft(1);
if (approx.equals(Long.ZERO)) {
return other.isNegative() ? Long.ONE : Long.NEG_ONE;
return divisor.isNegative() ? Long.ONE : Long.NEG_ONE;
} else {
rem = this.subtract(other.multiply(approx));
res = approx.add(rem.div(other));
rem = this.subtract(divisor.multiply(approx));
res = approx.add(rem.div(divisor));
return res;
}
}
} else if (other.equals(Long.MIN_SIGNED_VALUE)) {
} else if (divisor.equals(Long.MIN_VALUE))
return this.unsigned ? Long.UZERO : Long.ZERO;
}
if (this.isNegative()) {
if (other.isNegative()) {
return this.negate().div(other.negate());
} else {
return this.negate().div(other).negate();
}
} else if (other.isNegative()) {
return this.div(other.negate()).negate();
}
if (divisor.isNegative())
return this.negate().div(divisor.negate());
return this.negate().div(divisor).negate();
} else if (divisor.isNegative())
return this.div(divisor.negate()).negate();

@@ -807,20 +821,20 @@ // Repeat the following until the remainder is less than other: find a

rem = this;
while (rem.greaterThanOrEqual(other)) {
while (rem.greaterThanOrEqual(divisor)) {
// Approximate the result of division. This may be a little greater or
// smaller than the actual value.
approx = Math.max(1, Math.floor(rem.toNumber() / other.toNumber()));
approx = Math.max(1, Math.floor(rem.toNumber() / divisor.toNumber()));
// We will tweak the approximate result by changing it in the 48-th digit or
// the smallest non-fractional digit, whichever is larger.
var log2 = Math.ceil(Math.log(approx) / Math.LN2);
var delta = (log2 <= 48) ? 1 : Math.pow(2, log2 - 48);
var log2 = Math.ceil(Math.log(approx) / Math.LN2),
delta = (log2 <= 48) ? 1 : Math.pow(2, log2 - 48),
// Decrease the approximation until it is smaller than the remainder. Note
// that if it is too large, the product overflows and is negative.
var approxRes = Long.fromNumber(approx);
var approxRem = approxRes.multiply(other);
approxRes = Long.fromNumber(approx),
approxRem = approxRes.multiply(divisor);
while (approxRem.isNegative() || approxRem.greaterThan(rem)) {
approx -= delta;
approxRes = Long.fromNumber(approx, this.unsigned);
approxRem = approxRes.multiply(other);
approxRem = approxRes.multiply(divisor);
}

@@ -830,5 +844,4 @@

// infinite recursion since we would make no progress.
if (approxRes.isZero()) {
if (approxRes.isZero())
approxRes = Long.ONE;
}

@@ -842,13 +855,16 @@ res = res.add(approxRes);

/**
* Returns this Long modulo the given one.
* @param {Long} other Long by which to mod.
* @return {!Long} This Long modulo the given one.
* Returns this Long modulo the specified.
* @param {!Long|number|string} divisor Divisor
* @returns {!Long} Remainder
* @expose
*/
Long.prototype.modulo = function(other) {
return this.subtract(this.div(other).multiply(other));
Long.prototype.modulo = function(divisor) {
if (!Long.isLong(divisor))
divisor = Long.valueOf(divisor);
return this.subtract(this.div(divisor).multiply(divisor));
};
/**
* @return {!Long} The bitwise-NOT of this value.
* Returns the bitwise NOT of this Long.
* @returns {!Long}
* @expose

@@ -861,8 +877,10 @@ */

/**
* Returns the bitwise-AND of this Long and the given one.
* @param {Long} other The Long with which to AND.
* @return {!Long} The bitwise-AND of this and the other.
* Returns the bitwise AND of this Long and the specified.
* @param {!Long|number|string} other Other Long
* @returns {!Long}
* @expose
*/
Long.prototype.and = function(other) {
if (!Long.isLong(other))
other = Long.valueOf(other);
return Long.fromBits(this.low & other.low, this.high & other.high, this.unsigned);

@@ -872,8 +890,10 @@ };

/**
* Returns the bitwise-OR of this Long and the given one.
* @param {Long} other The Long with which to OR.
* @return {!Long} The bitwise-OR of this and the other.
* Returns the bitwise OR of this Long and the specified.
* @param {!Long|number|string} other Other Long
* @returns {!Long}
* @expose
*/
Long.prototype.or = function(other) {
if (!Long.isLong(other))
other = Long.valueOf(other);
return Long.fromBits(this.low | other.low, this.high | other.high, this.unsigned);

@@ -883,8 +903,10 @@ };

/**
* Returns the bitwise-XOR of this Long and the given one.
* @param {Long} other The Long with which to XOR.
* @return {!Long} The bitwise-XOR of this and the other.
* Returns the bitwise XOR of this Long and the given one.
* @param {!Long|number|string} other Other Long
* @returns {!Long}
* @expose
*/
Long.prototype.xor = function(other) {
if (!Long.isLong(other))
other = Long.valueOf(other);
return Long.fromBits(this.low ^ other.low, this.high ^ other.high, this.unsigned);

@@ -895,7 +917,9 @@ };

* Returns this Long with bits shifted to the left by the given amount.
* @param {number} numBits The number of bits by which to shift.
* @return {!Long} This shifted to the left by the given amount.
* @param {number|!Long} numBits Number of bits
* @returns {!Long} Shifted Long
* @expose
*/
Long.prototype.shiftLeft = function(numBits) {
if (Long.isLong(numBits))
numBits = numBits.toInt();
if ((numBits &= 63) === 0)

@@ -910,8 +934,10 @@ return this;

/**
* Returns this Long with bits shifted to the right by the given amount.
* @param {number} numBits The number of bits by which to shift.
* @return {!Long} This shifted to the right by the given amount.
* Returns this Long with bits arithmetically shifted to the right by the given amount.
* @param {number|!Long} numBits Number of bits
* @returns {!Long} Shifted Long
* @expose
*/
Long.prototype.shiftRight = function(numBits) {
if (Long.isLong(numBits))
numBits = numBits.toInt();
if ((numBits &= 63) === 0)

@@ -926,14 +952,14 @@ return this;

/**
* Returns this Long with bits shifted to the right by the given amount, with
* the new top bits matching the current sign bit.
* @param {number} numBits The number of bits by which to shift.
* @return {!Long} This shifted to the right by the given amount, with
* zeros placed into the new leading bits.
* Returns this Long with bits logically shifted to the right by the given amount.
* @param {number|!Long} numBits Number of bits
* @returns {!Long} Shifted Long
* @expose
*/
Long.prototype.shiftRightUnsigned = function(numBits) {
if (Long.isLong(numBits))
numBits = numBits.toInt();
numBits &= 63;
if (numBits == 0) {
if (numBits === 0)
return this;
} else {
else {
var high = this.high;

@@ -943,7 +969,6 @@ if (numBits < 32) {

return Long.fromBits((low >>> numBits) | (high << (32 - numBits)), high >>> numBits, this.unsigned);
} else if (numBits == 32) {
} else if (numBits === 32)
return Long.fromBits(high, 0, this.unsigned);
} else {
else
return Long.fromBits(high >>> (numBits - 32), 0, this.unsigned);
}
}

@@ -953,41 +978,30 @@ };

/**
* @return {!Long} Signed long
* Converts this Long to signed.
* @returns {!Long} Signed long
* @expose
*/
Long.prototype.toSigned = function() {
var l = this.clone();
l.unsigned = false;
return l;
if (!this.unsigned)
return this;
return new Long(this.low, this.high, false);
};
/**
* @return {!Long} Unsigned long
* Converts this Long to unsigned.
* @returns {!Long} Unsigned long
* @expose
*/
Long.prototype.toUnsigned = function() {
var l = this.clone();
l.unsigned = true;
return l;
if (this.unsigned)
return this;
return new Long(this.low, this.high, true);
};
/**
* @return {Long} Cloned instance with the same low/high bits and unsigned flag.
* @expose
*/
Long.prototype.clone = function() {
return new Long(this.low, this.high, this.unsigned);
};
// Enable module loading if available
if (typeof module != 'undefined' && module["exports"]) { // CommonJS
/* CommonJS */ if (typeof module !== 'undefined' && module["exports"])
module["exports"] = Long;
} else if (typeof define != 'undefined' && define["amd"]) { // AMD
define("Math/Long", [], function() { return Long; });
} else { // Shim
if (!global["dcodeIO"]) {
global["dcodeIO"] = {};
}
global["dcodeIO"]["Long"] = Long;
}
/* AMD */ else if (typeof define === 'function' && define["amd"])
define(function() { return Long; });
/* Global */ else
(global["dcodeIO"] = global["dcodeIO"] || {})["Long"] = Long;
})(this);

@@ -23,5 +23,6 @@ // Copyright 2009 The Closure Library Authors. All Rights Reserved.

// goog.provide('goog.math.Long');
var goog = {};
goog.math = {};
var goog = {}; goog.math = {};
/**

@@ -314,3 +315,4 @@ * Constructs a 64-bit two's-complement integer, given its low and high 32-bit

var remDiv = rem.div(radixToPower);
var intval = rem.subtract(remDiv.multiply(radixToPower)).toInt();
var intval = rem.subtract(remDiv.multiply(radixToPower)).toInt() >>> 0; // wraps around for base 36 (dcode)
console.log(intval);
var digits = intval.toString(radix);

@@ -317,0 +319,0 @@

@@ -29,3 +29,3 @@ /*

test.equal(longVal.toString(), "9223372036854775807");
var longVal2 = new Long(longVal);
var longVal2 = Long.valueOf(longVal);
test.equal(longVal2.toNumber(), 9223372036854775807);

@@ -37,6 +37,4 @@ test.equal(longVal2.toString(), "9223372036854775807");

// Let's assume signed goog.math.Long works as expected because the people at Google are pretty smart.
// Let's assume goog.math.Long has been tested properly and focus on our extensions:
// So let's focus on my probably not-so-smart extensions:
"toString": function(test) {

@@ -48,19 +46,13 @@ var longVal = Long.fromBits(0xFFFFFFFF, 0xFFFFFFFF, true);

test.equal(longVal.toString(8), "1777777777777777777777");
// #7
// #7, obviously wrong in goog.math.Long
test.equal(Long.fromString("zzzzzz", 36).toString(36), "zzzzzz");
test.equal(Long.fromString("-zzzzzz", 36).toString(36), "-zzzzzz");
test.done();
},
// This one is obviously wrong in goog.math.long itself:
/* "base36": function(test) {
test.equal(gmLong.fromString("zzzzzz", 36).toString(36), "zzzzzz");
test.done();
}, */
"unsigned": {
"min/max": function(test) {
test.equal(Long.MIN_SIGNED_VALUE.toString(), "-9223372036854775808");
test.equal(Long.MAX_SIGNED_VALUE.toString(), "9223372036854775807");
test.equal(Long.MIN_UNSIGNED_VALUE.toString(), "0");
test.equal(Long.MIN_VALUE.toString(), "-9223372036854775808");
test.equal(Long.MAX_VALUE.toString(), "9223372036854775807");
test.equal(Long.MAX_UNSIGNED_VALUE.toString(), "18446744073709551615");

@@ -111,5 +103,5 @@ test.done();

"max_unsigned_sub_max_signed": function(test) {
var longVal = Long.MAX_UNSIGNED_VALUE.subtract(Long.MAX_SIGNED_VALUE).subtract(Long.ONE);
test.equal(longVal.toNumber(), Long.MAX_SIGNED_VALUE);
test.equal(longVal.toString(), Long.MAX_SIGNED_VALUE.toString());
var longVal = Long.MAX_UNSIGNED_VALUE.subtract(Long.MAX_VALUE).subtract(Long.ONE);
test.equal(longVal.toNumber(), Long.MAX_VALUE);
test.equal(longVal.toString(), Long.MAX_VALUE.toString());
test.done();

@@ -140,3 +132,3 @@ },

"max_unsigned_div_max_signed": function(test) {
var longVal = Long.MAX_UNSIGNED_VALUE.div(Long.MAX_SIGNED_VALUE);
var longVal = Long.MAX_UNSIGNED_VALUE.div(Long.MAX_VALUE);
test.equal(longVal.toNumber(), 2);

@@ -149,3 +141,3 @@ test.equal(longVal.toString(), "2");

var longVal = Long.MAX_UNSIGNED_VALUE.div(Long.fromInt(-2));
test.equal(longVal.toNumber(), -Long.MAX_SIGNED_VALUE);
test.equal(longVal.toNumber(), -Long.MAX_VALUE);
test.done();

@@ -155,28 +147,6 @@ },

"min_signed_div_one": function(test) {
var longVal = Long.MIN_SIGNED_VALUE.div(Long.ONE);
var longVal = Long.MIN_VALUE.div(Long.ONE);
test.equal(longVal.toNumber(), Long.MIN_VALUE);
test.done();
}
},
// FIXME: There is no support for NaN or +/-Infinity
// "NaN": function(test) {
// test.ok(isNan(Long.fromNumber(NaN).toNumber());
// test.strictEqual(Long.fromNumber(+Infinity).toNumber(), +Infinity);
// test.strictEqual(Long.fromNumber(-Infinity).toNumber(), -Infinity);
// test.done();
// }
// One option could be to store NaN, Infinity etc. in high and set low to 0, while making sure to convert it in a
// proper way as soon as any math is called upon it. This might be as simple as that each of these values always
// "infects" other values, thus remaining untouched respectively changing the base long to its value.
//
// To clarify that, it all becomes zero atm, which usually is good enough but not perfect:
"NaN": function(test) {
test.strictEqual(Long.fromNumber(NaN), Long.ZERO);
test.strictEqual(Long.fromNumber(+Infinity), Long.ZERO);
test.strictEqual(Long.fromNumber(-Infinity), Long.ZERO);
test.strictEqual(Long.fromString(NaN+""), Long.ZERO);
test.strictEqual(Long.fromString(+Infinity+""), Long.ZERO);
test.strictEqual(Long.fromString(-Infinity+""), Long.ZERO);
test.done();
}

@@ -183,0 +153,0 @@ };

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc