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:
可选low: string | number | bigintThe low (signed) 32 bits of the long
可选high: number | booleanThe high (signed) 32 bits of the long
可选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.
静态MAX_Maximum unsigned value.
静态MAX_Maximum signed value.
静态MIN_Minimum signed value.
静态NEG_Signed negative one.
静态ONESigned one.
静态TWO_静态UONEUnsigned one.
静态UZEROUnsigned zero.
静态ZEROSigned zero
An indicator used to reliably determine if an object is a Long or not.
This is an alias of Long.isZero
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.
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.negate
Returns the Negation of this Long's value.
Returns the bitwise NOT of this Long.
Converts the Long to a BigInt (arbitrary precision).
Converts this Long to its byte representation.
可选le: booleanWhether 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
可选options: EJSONOptionsConverts 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 this Long to unsigned.
静态fromReturns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned.
The number in question
可选unsigned: booleanWhether unsigned or not, defaults to signed
The corresponding Long value
静态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
可选unsigned: booleanWhether unsigned or not, defaults to signed
The corresponding Long value
静态fromCreates a Long from its byte representation.
Byte representation
可选unsigned: booleanWhether unsigned or not, defaults to signed
可选le: booleanWhether little or big endian, defaults to big endian
The corresponding Long value
静态fromCreates a Long from its big endian byte representation.
Big endian byte representation
可选unsigned: booleanWhether unsigned or not, defaults to signed
The corresponding Long value
静态fromCreates a Long from its little endian byte representation.
Little endian byte representation
可选unsigned: booleanWhether unsigned or not, defaults to signed
The corresponding Long value
静态from可选options: EJSONOptions静态fromReturns a Long representing the given 32 bit integer value.
The 32 bit integer in question
可选unsigned: booleanWhether unsigned or not, defaults to signed
The corresponding Long value
静态fromReturns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned.
The number in question
可选unsigned: booleanWhether unsigned or not, defaults to signed
The corresponding Long value
静态fromReturns a Long representation of the given string, written using the specified radix.
The textual representation of the Long
可选unsigned: booleanWhether unsigned or not, defaults to signed
可选radix: numberThe radix in which the text is written (2-36), defaults to 10
The corresponding Long value
静态from静态is
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.