# class Integer

## Members

`Integer`

### Integer.`ONE`

- Static
- This member is static

`Integer`

### Integer.`ZERO`

- Static
- This member is static

## Constructor

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.

## Methods

### abs

()Returns a Integer whose value is the absolute value of this

### add

(`Integer`

`other`)

Returns the sum of this and the given Integer.

### and

(`Integer`

`other`)

Returns the bitwise-AND of this Integer and the given one.

### compare

(`Integer`

`other`)

Compares this Integer with the given one.

### divide

(`Integer`

`other`)

Returns this Integer divided by the given one.

### equals

(`Integer`

`other`)

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.

- Static
- This function is static

### Integer.fromBuffer

(`Buffer`

`buf`)

Returns an Integer representation of a given big endian Buffer. The internal representation of bits contains bytes in groups of 4

- Static
- This function is static

### Integer.fromInt

(`number`

`value`)

Returns an Integer representing the given (32-bit) integer value.

- Static
- This function is static

### Integer.fromNumber

(`number`

`value`)

Returns an Integer representing the given value, provided that it is a finite number. Otherwise, zero is returned.

- Static
- This function is static

### Integer.fromString

(`string`

`str`, [

`number`

`opt_radix`])

Returns an Integer representation of the given string, written using the given radix.

- Static
- This function is static

### getBits

(`number`

`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).

### getBitsUnsigned

(`number`

`index`)

Returns the index-th 32-bit piece as an unsigned number.

### getSign

()### greaterThan

(`Integer`

`other`)

### greaterThanOrEqual

(`Integer`

`other`)

### inspect

()Provide the name of the constructor and the string representation

### isNegative

()### isOdd

()### isZero

()### lessThan

(`Integer`

`other`)

### lessThanOrEqual

(`Integer`

`other`)

### modulo

(`Integer`

`other`)

Returns this Integer modulo the given one.

### multiply

(`Integer`

`other`)

Returns the product of this and the given Integer.

### negate

()### not

()### notEquals

(`Integer`

`other`)

### or

(`Integer`

`other`)

Returns the bitwise-OR of this Integer and the given one.

### shiftLeft

(`number`

`numBits`)

Returns this value with bits shifted to the left by the given amount.

### shiftRight

(`number`

`numBits`)

Returns this value with bits shifted to the right by the given amount.

### shorten

(`number`

`numBits`)

Returns an integer with only the first numBits bits of this value, sign extended from the final bit.

### subtract

(`Integer`

`other`)

Returns the difference of this and the given Integer.

### Integer.toBuffer

(`Integer`

`value`)

Returns a big endian buffer representation of an Integer. Internally the bits are represented using 4 bytes groups (numbers), in the Buffer representation there might be the case where we need less than the 4 bytes. For example: 0x00000001 -> ‘01’, 0xFFFFFFFF -> ‘FF’, 0xFFFFFF01 -> ‘FF01’

- Static
- This function is static

### toInt

()Returns the value, assuming it is a 32-bit integer.

### toJSON

()Returns the string representation. Method used by the native JSON.stringify() to serialize this instance.

### toNumber

()### toString

([`number`

`opt_radix`])

### xor

(`Integer`

`other`)

Returns the bitwise-XOR of this Integer and the given one.