goog.math.Integer
Classgoog.math.Integer(bits, sign)
Constructs a two's-complement integer an array containing bits of the integer in 32-bit (signed) pieces, given in little-endian order (i.e., lowest-order bits in the first piece), and the sign of -1 or 0. See the from* functions below for other convenient ways of constructing Integers. The internal representation of an integer is an array of 32-bit signed pieces, along with a sign (0 or -1) that indicates the contents of all the other 32-bit pieces out to infinity. 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.
bits
{Array
.<number
>}
sign
{number
}
.ONE
{!goog.math.Integer
}.ZERO
{!goog.math.Integer
}.add(other)
Returns the sum of this and the given Integer.
other
{goog.math.Integer
}
goog.math.Integer
}
.and(other)
Returns the bitwise-AND of this Integer and the given one.
other
{goog.math.Integer
}
goog.math.Integer
}
.compare(other)
Compares this Integer with the given one.
other
{goog.math.Integer
}
number
}
.divide(other)
Returns this Integer divided by the given one.
other
{goog.math.Integer
}
goog.math.Integer
}
.equals(other)
other
{goog.math.Integer
}
boolean
}
.fromBits(bits)
Returns a Integer representing the value that comes by concatenating the given entries, each is assumed to be 32 signed bits, given in little-endian order (lowest order bits in the lowest index), and sign-extending the highest order 32-bit value.
bits
{Array
.<number
>}
goog.math.Integer
}
.fromInt(value)
Returns an Integer representing the given (32-bit) integer value.
value
{number
}
goog.math.Integer
}
.fromNumber(value)
Returns an Integer representing the given value, provided that it is a finite number. Otherwise, zero is returned.
value
{number
}
goog.math.Integer
}
.fromString(str, opt_radix)
Returns an Integer representation of the given string, written using the given radix.
str
{string
}
opt_radix
{number
=}
goog.math.Integer
}
.getBits(index)
Returns the index-th 32-bit (signed) piece of the Integer according to little-endian order (i.e., index 0 contains the smallest bits).
index
{number
}
number
}
.getBitsUnsigned(index)
Returns the index-th 32-bit piece as an unsigned number.
index
{number
}
number
}
.getSign()
number
}
.greaterThan(other)
other
{goog.math.Integer
}
boolean
}
.greaterThanOrEqual(other)
other
{goog.math.Integer
}
boolean
}
.isNegative()
boolean
}
.isOdd()
boolean
}
.isZero()
boolean
}
.lessThan(other)
other
{goog.math.Integer
}
boolean
}
.lessThanOrEqual(other)
other
{goog.math.Integer
}
boolean
}
.modulo(other)
Returns this Integer modulo the given one.
other
{goog.math.Integer
}
goog.math.Integer
}
.multiply(other)
Returns the product of this and the given Integer.
other
{goog.math.Integer
}
goog.math.Integer
}
.negate()
goog.math.Integer
}
.not()
goog.math.Integer
}
.notEquals(other)
other
{goog.math.Integer
}
boolean
}
.or(other)
Returns the bitwise-OR of this Integer and the given one.
other
{goog.math.Integer
}
goog.math.Integer
}
.shiftLeft(numBits)
Returns this value with bits shifted to the left by the given amount.
numBits
{number
}
goog.math.Integer
}
.shiftRight(numBits)
Returns this value with bits shifted to the right by the given amount.
numBits
{number
}
goog.math.Integer
}
.shorten(numBits)
Returns an integer with only the first numBits bits of this value, sign extended from the final bit.
numBits
{number
}
goog.math.Integer
}
.subtract(other)
Returns the difference of this and the given Integer.
other
{goog.math.Integer
}
goog.math.Integer
}
.toInt()
Returns the value, assuming it is a 32-bit integer.
number
}
.toNumber()
number
}
.toString(opt_radix)
opt_radix
{number
=}
string
}
.xor(other)
Returns the bitwise-XOR of this Integer and the given one.
other
{goog.math.Integer
}
goog.math.Integer
}