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.
Acceptable signatures are:
The low (signed) 32 bits of the long
The high (signed) 32 bits of the long
Whether unsigned or not, defaults to signed
An indicator used to reliably determine if an object is a Long or not.
The high 32 bits as a signed value.
The low 32 bits as a signed value.
Whether unsigned or not.
Maximum unsigned value.
Maximum signed value.
Minimum signed value.
Signed negative one.
Signed one.
Unsigned one.
Unsigned zero.
Signed zero
This is an alias of Long.compare
This is an alias of Long.divide
This is an alias of Long.equals
This is an alias of Long.isZero
This is an alias of Long.greaterThanOrEqual
Gets the high 32 bits as a signed integer.
Gets the high 32 bits as an unsigned integer.
Gets the low 32 bits as a signed integer.
Gets the low 32 bits as an unsigned integer.
Gets the number of bits needed to represent the absolute value of this Long.
This is an alias of Long.greaterThan
This is an alias of Long.greaterThanOrEqual
Tests if this Long's value is even.
Tests if this Long's value is negative.
Tests if this Long's value is odd.
Tests if this Long's value is positive.
Tests if this Long's value equals zero.
This is an alias of Long.lessThanOrEqual
This is an alias of Long.lessThanOrEqual
This is an alias of Long.modulo
This is an alias of Long.multiply
This is an alias of Long.notEquals
This is an alias of Long.negate
Returns the Negation of this Long's value.
This is an alias of Long.notEquals
Returns the bitwise NOT of this Long.
This is an alias of Long.modulo
This is an alias of Long.shiftLeft
This is an alias of Long.shiftRight
This is an alias of Long.shiftRightUnsigned
This is an alias of Long.shiftRightUnsigned
This is an alias of Long.subtract
Converts the Long to a BigInt (arbitrary precision).
Converts this Long to its byte representation.
Whether little or big endian, defaults to big endian
Byte representation
Converts this Long to its big endian byte representation.
Big endian byte representation
Converts this Long to its little endian byte representation.
Little endian byte representation
Converts the Long to a 32 bit integer, assuming it is a 32 bit integer.
Converts the Long to a the nearest floating-point representation of this value (double, 53 bit mantissa).
Converts this Long to signed.
Converts the Long to a string written in the specified radix.
Radix (2-36), defaults to 10
Converts this Long to unsigned.
Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned.
The number in question
Whether unsigned or not, defaults to signed
The corresponding Long value
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.
The low 32 bits
The high 32 bits
Whether unsigned or not, defaults to signed
The corresponding Long value
Creates a Long from its byte representation.
Byte representation
Whether unsigned or not, defaults to signed
Whether little or big endian, defaults to big endian
The corresponding Long value
Creates a Long from its big endian byte representation.
Big endian byte representation
Whether unsigned or not, defaults to signed
The corresponding Long value
Creates a Long from its little endian byte representation.
Little endian byte representation
Whether unsigned or not, defaults to signed
The corresponding Long value
Returns a Long representing the given 32 bit integer value.
The 32 bit integer in question
Whether unsigned or not, defaults to signed
The corresponding Long value
Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned.
The number in question
Whether unsigned or not, defaults to signed
The corresponding Long value
Returns a Long representation of the given string, written using the specified radix.
The textual representation of the Long
Whether unsigned or not, defaults to signed
The radix in which the text is written (2-36), defaults to 10
The corresponding Long value
Converts the specified value to a Long.
Whether unsigned or not, defaults to signed
Tests if the specified object is a Long.
Generated using TypeDoc
A class representing a 64-bit integer
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 found as static properties on this class.