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:
Optional
low: string | number | bigintThe low (signed) 32 bits of the long
Optional
high: number | booleanThe high (signed) 32 bits of the long
Optional
unsigned: booleanWhether unsigned or not, defaults to signed
The high 32 bits as a signed value.
The low 32 bits as a signed value.
Whether unsigned or not.
Static
MAX_Maximum unsigned value.
Static
MAX_Maximum signed value.
Static
MIN_Minimum signed value.
Static
NEG_Signed negative one.
Static
ONESigned one.
Static
TWO_Static
UONEUnsigned one.
Static
UZEROUnsigned zero.
Static
ZEROSigned zero
An indicator used to reliably determine if an object is a Long or not.
This is an alias of compare
This is an alias of equals
This is an alias of isZero
This is an alias of greaterThanOrEqual
This is an alias of greaterThan
This is an alias of greaterThanOrEqual
This is an alias of lessThanOrEqual
This is an alias of lessThan.
This is an alias of lessThanOrEqual
This is an alias of notEquals
This is an alias of notEquals
This is an alias of shiftRight
This is an alias of shiftRightUnsigned
This is an alias of shiftRightUnsigned
Optional
options: EJSONOptionsStatic
fromReturns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned.
The number in question
Optional
unsigned: booleanWhether unsigned or not, defaults to signed
The corresponding Long value
Static
fromReturns 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
Optional
unsigned: booleanWhether unsigned or not, defaults to signed
The corresponding Long value
Static
fromCreates a Long from its byte representation.
Byte representation
Optional
unsigned: booleanWhether unsigned or not, defaults to signed
Optional
le: booleanWhether little or big endian, defaults to big endian
The corresponding Long value
Static
fromStatic
fromStatic
fromOptional
options: EJSONOptionsStatic
fromStatic
fromReturns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned.
The number in question
Optional
unsigned: booleanWhether unsigned or not, defaults to signed
The corresponding Long value
Static
fromReturns a Long representation of the given string, written using the specified radix.
The textual representation of the Long
Optional
unsigned: booleanWhether unsigned or not, defaults to signed
Optional
radix: numberThe radix in which the text is written (2-36), defaults to 10
The corresponding Long value
Static
fromStatic
isGenerated using TypeDoc
A class representing a 64-bit integer
Remarks
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.