Home

# Class goog.math.Integer

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.

Instance Method Summary
| `add(?goog.math.Integer other) ⇒ !goog.math.Integer` Returns the sum of this and the given Integer.
| `and(?goog.math.Integer other) ⇒ !goog.math.Integer` Returns the bitwise-AND of this Integer and the given one.
| `compare(?goog.math.Integer other) ⇒ number` Compares this Integer with the given one.
| `divide(?goog.math.Integer other) ⇒ !goog.math.Integer` Returns this Integer divided by the given one.
| `equals(?goog.math.Integer other) ⇒ boolean`
| `getBits(number index) ⇒ number` Returns the index-th 32-bit (signed) piece of the Integer according to little-endian order (i.e., index 0 contains the smallest bits).
| `getBitsUnsigned(number index) ⇒ number` Returns the index-th 32-bit piece as an unsigned number.
| `getSign() ⇒ number`
| `greaterThan(?goog.math.Integer other) ⇒ boolean`
| `greaterThanOrEqual(?goog.math.Integer other) ⇒ boolean`
| `isNegative() ⇒ boolean`
| `isOdd() ⇒ boolean`
| `isZero() ⇒ boolean`
| `lessThan(?goog.math.Integer other) ⇒ boolean`
| `lessThanOrEqual(?goog.math.Integer other) ⇒ boolean`
| `modulo(?goog.math.Integer other) ⇒ !goog.math.Integer` Returns this Integer modulo the given one.
| `multiply(?goog.math.Integer other) ⇒ !goog.math.Integer` Returns the product of this and the given Integer.
| `negate() ⇒ !goog.math.Integer`
| `not() ⇒ !goog.math.Integer`
| `notEquals(?goog.math.Integer other) ⇒ boolean`
| `or(?goog.math.Integer other) ⇒ !goog.math.Integer` Returns the bitwise-OR of this Integer and the given one.
| `shiftLeft(number numBits) ⇒ !goog.math.Integer` Returns this value with bits shifted to the left by the given amount.
| `shiftRight(number numBits) ⇒ !goog.math.Integer` Returns this value with bits shifted to the right by the given amount.
| `shorten(number numBits) ⇒ !goog.math.Integer` Returns an integer with only the first numBits bits of this value, sign extended from the final bit.
| `subtract(?goog.math.Integer other) ⇒ !goog.math.Integer` Returns the difference of this and the given Integer.
| `toInt() ⇒ number` Returns the value, assuming it is a 32-bit integer.
| `toNumber() ⇒ number`
| `toString(number= opt_radix) ⇒ string`
| `xor(?goog.math.Integer other) ⇒ !goog.math.Integer` Returns the bitwise-XOR of this Integer and the given one.

Static Method Summary
| `carry16_(?Array.<number> bits, number index)` Carries any overflow from the given index into later entries.
| `fromBits(?Array.<number> bits) ⇒ !goog.math.Integer` 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.
| `fromInt(number value) ⇒ !goog.math.Integer` Returns an Integer representing the given (32-bit) integer value.
| `fromNumber(number value) ⇒ !goog.math.Integer` Returns an Integer representing the given value, provided that it is a finite number. Otherwise, zero is returned.
| `fromString(string str, number= opt_radix) ⇒ !goog.math.Integer` Returns an Integer representation of the given string, written using the given radix.