math.Long Extends
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. 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.

Inheritance

Constructor

goog.math.Long(lowhigh)

Parameters

low : number
The low (signed) 32 bits of the long.
high : number
The high (signed) 32 bits of the long.

Instance Methods

Public Protected Private
Defined in goog.math.Long
add(other) !goog.math.Long
Returns the sum of this and the given Long.
Arguments:
other : goog.math.Long
Long to add to this one.
Returns: !goog.math.Long  The sum of this and the given Long.
code »
and(other) !goog.math.Long
Returns the bitwise-AND of this Long and the given one.
Arguments:
other : goog.math.Long
The Long with which to AND.
Returns: !goog.math.Long  The bitwise-AND of this and the other.
code »
compare(other) number
Compares this Long with the given one.
Arguments:
other : goog.math.Long
Long to compare against.
Returns: number  0 if they are the same, 1 if the this is greater, and -1 if the given one is greater.
code »
div(other) !goog.math.Long
Returns this Long divided by the given one.
Arguments:
other : goog.math.Long
Long by which to divide.
Returns: !goog.math.Long  This Long divided by the given one.
code »
equals(other) boolean
No description.
Arguments:
other : goog.math.Long
Long to compare against.
Returns: boolean  Whether this Long equals the other.
code »
getHighBits() number
No description.
Returns: number  The high 32-bits as a signed value.
code »
getLowBits() number
No description.
Returns: number  The low 32-bits as a signed value.
code »
getLowBitsUnsigned() number
No description.
Returns: number  The low 32-bits as an unsigned value.
code »
getNumBitsAbs() number
No description.
Returns: number  Returns the number of bits needed to represent the absolute value of this Long.
code »
greaterThan(other) boolean
No description.
Arguments:
other : goog.math.Long
Long to compare against.
Returns: boolean  Whether this Long is greater than the other.
code »
greaterThanOrEqual(other) boolean
No description.
Arguments:
other : goog.math.Long
Long to compare against.
Returns: boolean  Whether this Long is greater than or equal to the other.
code »
isNegative() boolean
No description.
Returns: boolean  Whether this value is negative.
code »
isOdd() boolean
No description.
Returns: boolean  Whether this value is odd.
code »
isZero() boolean
No description.
Returns: boolean  Whether this value is zero.
code »
lessThan(other) boolean
No description.
Arguments:
other : goog.math.Long
Long to compare against.
Returns: boolean  Whether this Long is less than the other.
code »
lessThanOrEqual(other) boolean
No description.
Arguments:
other : goog.math.Long
Long to compare against.
Returns: boolean  Whether this Long is less than or equal to the other.
code »
modulo(other) !goog.math.Long
Returns this Long modulo the given one.
Arguments:
other : goog.math.Long
Long by which to mod.
Returns: !goog.math.Long  This Long modulo the given one.
code »
multiply(other) !goog.math.Long
Returns the product of this and the given long.
Arguments:
other : goog.math.Long
Long to multiply with this.
Returns: !goog.math.Long  The product of this and the other.
code »
negate() !goog.math.Long
No description.
Returns: !goog.math.Long  The negation of this value.
code »
not() !goog.math.Long
No description.
Returns: !goog.math.Long  The bitwise-NOT of this value.
code »
notEquals(other) boolean
No description.
Arguments:
other : goog.math.Long
Long to compare against.
Returns: boolean  Whether this Long does not equal the other.
code »
or(other) !goog.math.Long
Returns the bitwise-OR of this Long and the given one.
Arguments:
other : goog.math.Long
The Long with which to OR.
Returns: !goog.math.Long  The bitwise-OR of this and the other.
code »
shiftLeft(numBits) !goog.math.Long
Returns this Long with bits shifted to the left by the given amount.
Arguments:
numBits : number
The number of bits by which to shift.
Returns: !goog.math.Long  This shifted to the left by the given amount.
code »
shiftRight(numBits) !goog.math.Long
Returns this Long with bits shifted to the right by the given amount.
Arguments:
numBits : number
The number of bits by which to shift.
Returns: !goog.math.Long  This shifted to the right by the given amount.
code »
shiftRightUnsigned(numBits) !goog.math.Long
Returns this Long with bits shifted to the right by the given amount, with zeros placed into the new leading bits.
Arguments:
numBits : number
The number of bits by which to shift.
Returns: !goog.math.Long  This shifted to the right by the given amount, with zeros placed into the new leading bits.
code »
subtract(other) !goog.math.Long
Returns the difference of this and the given Long.
Arguments:
other : goog.math.Long
Long to subtract from this.
Returns: !goog.math.Long  The difference of this and the given Long.
code »
toInt() number
No description.
Returns: number  The value, assuming it is a 32-bit integer.
code »
toNumber() number
No description.
Returns: number  The closest floating-point representation to this value.
code »
toString(opt_radix) string
No description.
Arguments:
opt_radix : number=
The radix in which the text should be written.
Returns: string  The textual representation of this value.
code »
xor(other) !goog.math.Long
Returns the bitwise-XOR of this Long and the given one.
Arguments:
other : goog.math.Long
The Long with which to XOR.
Returns: !goog.math.Long  The bitwise-XOR of this and the other.
code »

Instance Properties

Defined in goog.math.Long
high_ :
No description.
Code »
low_ :
No description.
Code »

Static Methods

goog.math.Long.fromBits(lowBitshighBits) !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.
Arguments:
lowBits : number
The low 32-bits.
highBits : number
The high 32-bits.
Returns: !goog.math.Long  The corresponding Long value.
code »
goog.math.Long.fromInt(value) !goog.math.Long
Returns a Long representing the given (32-bit) integer value.
Arguments:
value : number
The 32-bit integer in question.
Returns: !goog.math.Long  The corresponding Long value.
code »
goog.math.Long.fromNumber(value) !goog.math.Long
Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned.
Arguments:
value : number
The number in question.
Returns: !goog.math.Long  The corresponding Long value.
code »
goog.math.Long.fromString(stropt_radix) !goog.math.Long
Returns a Long representation of the given string, written using the given radix.
Arguments:
str : string
The textual representation of the Long.
opt_radix : number=
The radix in which the text is written.
Returns: !goog.math.Long  The corresponding Long value.
code »

Static Properties

goog.math.Long.IntCache_ :
A cache of the Long representations of small integer values.
Code »
goog.math.Long.MAX_VALUE : goog.math.Long
No description.
Code »
goog.math.Long.MIN_VALUE : goog.math.Long
No description.
Code »
goog.math.Long.NEG_ONE : goog.math.Long
No description.
Code »
goog.math.Long.ONE : goog.math.Long
No description.
Code »
goog.math.Long.TWO_PWR_16_DBL_ :
Number used repeated below in calculations. This must appear before the first call to any from* function below.
Code »
goog.math.Long.TWO_PWR_24_ : goog.math.Long
No description.
Code »
goog.math.Long.TWO_PWR_24_DBL_ :
No description.
Code »
goog.math.Long.TWO_PWR_31_DBL_ :
No description.
Code »
goog.math.Long.TWO_PWR_32_DBL_ :
No description.
Code »
goog.math.Long.TWO_PWR_48_DBL_ :
No description.
Code »
goog.math.Long.TWO_PWR_63_DBL_ :
No description.
Code »
goog.math.Long.TWO_PWR_64_DBL_ :
No description.
Code »
goog.math.Long.ZERO : goog.math.Long
No description.
Code »

Package math

Package Reference