goog.math.Long
Module ID |
---|
Represents 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.
new Long( arg0, arg1 )
Parameters |
|
---|
Instance Methods
this.add( other ) → goog.math.Long
goog.math.Long
Returns the sum of this and the given Long.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.and( other ) → goog.math.Long
goog.math.Long
Returns the bitwise-AND of this Long and the given one.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.compare( other ) → number
number
Compares this Long with the given one.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.div( other ) → goog.math.Long
goog.math.Long
Returns this Long divided by the given one.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.equals( other ) → boolean
boolean
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.getHighBits() → number
number
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getLowBits() → number
number
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getLowBitsUnsigned() → number
number
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getNumBitsAbs() → number
number
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.greaterThan( other ) → boolean
boolean
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.greaterThanOrEqual( other ) → boolean
boolean
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.hashCode() → number
number
Returns a hash code for this long object that similar java.lang.Long one.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.isNegative() → boolean
boolean
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.isOdd() → boolean
boolean
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.isSafeInteger() → boolean
boolean
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.isZero() → boolean
boolean
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.lessThan( other ) → boolean
boolean
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.lessThanOrEqual( other ) → boolean
boolean
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.modulo( other ) → goog.math.Long
goog.math.Long
Returns this Long modulo the given one.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.multiply( other ) → goog.math.Long
goog.math.Long
Returns the product of this and the given long.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.negate() → goog.math.Long
goog.math.Long
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.not() → goog.math.Long
goog.math.Long
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.notEquals( other ) → boolean
boolean
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.or( other ) → goog.math.Long
goog.math.Long
Returns the bitwise-OR of this Long and the given one.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.shiftLeft( numBits ) → goog.math.Long
goog.math.Long
Returns this Long with bits shifted to the left by the given amount.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.shiftRight( numBits ) → goog.math.Long
goog.math.Long
Returns this Long with bits shifted to the right by the given amount. The new leading bits match the current sign bit.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.shiftRightUnsigned( numBits ) → goog.math.Long
goog.math.Long
Returns this Long with bits shifted to the right by the given amount, with zeros placed into the new leading bits.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.subtract( other ) → goog.math.Long
goog.math.Long
Returns the difference of this and the given Long.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.toInt() → number
number
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.toNumber() → number
number
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.toString( opt_radix ) → string
string
this.toUnsignedString( opt_radix ) → string
string
this.xor( other ) → goog.math.Long
goog.math.Long
Returns the bitwise-XOR of this Long and the given one.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
Exported Functions
fromBits( lowBits, highBits ) → goog.math.Long
goog.math.Long
Returns a Long representing the 64-bit integer that comes by concatenating the given high and low bits. Each is assumed to use 32 bits.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
fromInt( value ) → goog.math.Long
goog.math.Long
Returns a Long representing the given (32-bit) integer value.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
fromNumber( value ) → goog.math.Long
goog.math.Long
Returns a Long representing the given value. NaN will be returned as zero. Infinity is converted to max value and -Infinity to min value.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
fromString( str, opt_radix ) → goog.math.Long
goog.math.Long
Returns a Long representation of the given string, written using the given radix.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
getMaxValue() → goog.math.Long
goog.math.Long
Parameters | None. | |
---|---|---|
Returns |
|
getMinValue() → goog.math.Long
goog.math.Long
Parameters | None. | |
---|---|---|
Returns |
|
getNegOne() → goog.math.Long
goog.math.Long
Parameters | None. | |
---|---|---|
Returns |
|
getOne() → goog.math.Long
goog.math.Long
Parameters | None. | |
---|---|---|
Returns |
|
getTwoPwr24() → goog.math.Long
goog.math.Long
Parameters | None. | |
---|---|---|
Returns |
|
getZero() → goog.math.Long
goog.math.Long
Parameters | None. | |
---|---|---|
Returns |
|
isStringInRange( str, opt_radix ) → boolean
boolean
Returns the boolean value of whether the input string is within a Long's range. Assumes an input string containing only numeric characters with an optional preceding '-'.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|