goog.math.Integer
Provided By |
---|
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.
new Integer( bits, sign )
Parameters |
|
---|
Instance Methods
this.abs() → goog.math.Integer
goog.math.Integer
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.add( other ) → goog.math.Integer
goog.math.Integer
Returns the sum of this and the given Integer.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.and( other ) → goog.math.Integer
goog.math.Integer
Returns the bitwise-AND of this Integer and the given one.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.compare( other ) → number
number
Compares this Integer with the given one.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.divide( other ) → goog.math.Integer
goog.math.Integer
Returns this Integer divided by the given one.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.divideAndRemainder( other ) → goog.math.Integer.DivisionResult
goog.math.Integer.DivisionResult
Returns this Integer divided by the given one, as well as the remainder of that division.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.equals( other ) → boolean
boolean
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.getBits( index ) → number
number
this.getBitsUnsigned( index ) → number
number
this.getSign() → number
number
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.greaterThan( other ) → boolean
boolean
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.greaterThanOrEqual( other ) → boolean
boolean
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.isNegative() → boolean
boolean
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.isOdd() → 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.Integer
goog.math.Integer
Returns this Integer modulo the given one.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.multiply( other ) → goog.math.Integer
goog.math.Integer
Returns the product of this and the given Integer.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.negate() → goog.math.Integer
goog.math.Integer
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.not() → goog.math.Integer
goog.math.Integer
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.notEquals( other ) → boolean
boolean
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.or( other ) → goog.math.Integer
goog.math.Integer
Returns the bitwise-OR of this Integer and the given one.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.shiftLeft( numBits ) → goog.math.Integer
goog.math.Integer
Returns this value with bits shifted to the left by the given amount.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.shiftRight( numBits ) → goog.math.Integer
goog.math.Integer
Returns this value with bits shifted to the right by the given amount.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.shorten( numBits ) → goog.math.Integer
goog.math.Integer
Returns an integer with only the first numBits bits of this value, sign extended from the final bit.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.subtract( other ) → goog.math.Integer
goog.math.Integer
Returns the difference of this and the given Integer.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.toInt() → number
number
Returns the value, assuming it is a 32-bit integer.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.toNumber() → number
number
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.toString( opt_radix ) → string
string
this.xor( other ) → goog.math.Integer
goog.math.Integer
Returns the bitwise-XOR of this Integer and the given one.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
Static Functions
Integer.fromBits( bits ) → goog.math.Integer
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.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
Integer.fromInt( value ) → goog.math.Integer
goog.math.Integer
Returns an Integer representing the given (32-bit) integer value.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
Integer.fromNumber( value ) → goog.math.Integer
goog.math.Integer
Returns an Integer representing the given value, provided that it is a finite number. Otherwise, zero is returned.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
Integer.fromString( str, opt_radix ) → goog.math.Integer
goog.math.Integer
Returns an Integer representation of the given string, written using the given radix.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
Static Properties
Integer.ONE → goog.math.Integer
goog.math.Integer
No information.
Integer.ZERO → goog.math.Integer
goog.math.Integer
No information.