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
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.
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
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
This is an alias of Long.greaterThan
This is an alias of Long.greaterThanOrEqual
This is an alias of Long.lessThanOrEqual
This is an alias of Long#lessThan.
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
This is an alias of Long.notEquals
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
Optional
options: OptionsStatic
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
fromStatic
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.