Home Reference Source
import Integer from 'neo4j-driver-core/lib/integer.js'
public class | source

Integer

Constructs a 64 bit two's-complement integer, given its low and high 32 bit values as signed integers. See exported functions for more convenient ways of operating integers. Use int() function to create new integers, isInt() to check if given object is integer, inSafeRange() to check if it is safe to convert given value to native number, toNumber() and toString() to convert given integer to number or string respectively.

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public

high: number

The high 32 bits as a signed value.

public

low: number

The low 32 bits as a signed value.

Method Summary

Public Methods
public

add(addend: Integer | number | string): Integer

Returns the sum of this and the specified Integer.

public

and(other: Integer | number | string): Integer

Returns the bitwise AND of this Integer and the specified.

public

compare(other: Integer | number | string): number

Compares this Integer's value with the specified's.

public

div(divisor: Integer | number | string): Integer

Returns this Integer divided by the specified.

public

equals(other: Integer | number | string): boolean

Tests if this Integer's value equals the specified's.

public

getHighBits(): number

Gets the high 32 bits as a signed integer.

public

getLowBits(): number

Gets the low 32 bits as a signed integer.

public

getNumBitsAbs(): number

Gets the number of bits needed to represent the absolute value of this Integer.

public

greaterThan(other: Integer | number | string): boolean

Tests if this Integer's value is greater than the specified's.

public

greaterThanOrEqual(other: Integer | number | string): boolean

Tests if this Integer's value is greater than or equal the specified's.

public
public

isEven(): boolean

Tests if this Integer's value is even.

public

isNegative(): boolean

Tests if this Integer's value is negative.

public

isOdd(): boolean

Tests if this Integer's value is odd.

public

isPositive(): boolean

Tests if this Integer's value is positive.

public

isZero(): boolean

Tests if this Integer's value equals zero.

public

lessThan(other: Integer | number | string): boolean

Tests if this Integer's value is less than the specified's.

public

lessThanOrEqual(other: Integer | number | string): boolean

Tests if this Integer's value is less than or equal the specified's.

public

modulo(divisor: Integer | number | string): Integer

Returns this Integer modulo the specified.

public

multiply(multiplier: Integer | number | string): Integer

Returns the product of this and the specified Integer.

public

Negates this Integer's value.

public

Returns the bitwise NOT of this Integer.

public

notEquals(other: Integer | number | string): boolean

Tests if this Integer's value differs from the specified's.

public

or(other: Integer | number | string): Integer

Returns the bitwise OR of this Integer and the specified.

public

shiftLeft(numBits: number | !Integer): Integer

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

public

shiftRight(numBits: number | !Integer): Integer

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

public

subtract(subtrahend: Integer | number | string): Integer

Returns the difference of this and the specified Integer.

public

toBigInt(): bigint

Converts the Integer to a BigInt representation of this value

public

toInt(): number

Converts the Integer to an exact javascript Number, assuming it is a 32 bit integer.

public

toNumber(): number

Converts the Integer to a the nearest floating-point representation of this value (double, 53 bit mantissa).

public

toString(radix: number=): string

Converts the Integer to a string written in the specified radix.

public

valueOf(): bigint

Converts the Integer to it primitive value.

since 5.4.0
public

xor(other: Integer | number | string): Integer

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

Public Constructors

public constructor() source

Public Members

public high: number source

The high 32 bits as a signed value.

public low: number source

The low 32 bits as a signed value.

Public Methods

public add(addend: Integer | number | string): Integer source

Returns the sum of this and the specified Integer.

Params:

NameTypeAttributeDescription
addend Integer | number | string
  • nullable: false

Addend

Return:

Integer (nullable: false)

Sum

public and(other: Integer | number | string): Integer source

Returns the bitwise AND of this Integer and the specified.

Params:

NameTypeAttributeDescription
other Integer | number | string
  • nullable: false

Other Integer

Return:

Integer (nullable: false)

public compare(other: Integer | number | string): number source

Compares this Integer's value with the specified's.

Params:

NameTypeAttributeDescription
other Integer | number | string
  • nullable: false

Other value

Return:

number

0 if they are the same, 1 if the this is greater and -1 if the given one is greater

public div(divisor: Integer | number | string): Integer source

Returns this Integer divided by the specified.

Params:

NameTypeAttributeDescription
divisor Integer | number | string
  • nullable: false

Divisor

Return:

Integer (nullable: false)

Quotient

public equals(other: Integer | number | string): boolean source

Tests if this Integer's value equals the specified's.

Params:

NameTypeAttributeDescription
other Integer | number | string
  • nullable: false

Other value

Return:

boolean

public getHighBits(): number source

Gets the high 32 bits as a signed integer.

Return:

number

Signed high bits

public getLowBits(): number source

Gets the low 32 bits as a signed integer.

Return:

number

Signed low bits

public getNumBitsAbs(): number source

Gets the number of bits needed to represent the absolute value of this Integer.

Return:

number

public greaterThan(other: Integer | number | string): boolean source

Tests if this Integer's value is greater than the specified's.

Params:

NameTypeAttributeDescription
other Integer | number | string
  • nullable: false

Other value

Return:

boolean

public greaterThanOrEqual(other: Integer | number | string): boolean source

Tests if this Integer's value is greater than or equal the specified's.

Params:

NameTypeAttributeDescription
other Integer | number | string
  • nullable: false

Other value

Return:

boolean

public inSafeRange(): * source

Return:

*

public isEven(): boolean source

Tests if this Integer's value is even.

Return:

boolean

public isNegative(): boolean source

Tests if this Integer's value is negative.

Return:

boolean

public isOdd(): boolean source

Tests if this Integer's value is odd.

Return:

boolean

public isPositive(): boolean source

Tests if this Integer's value is positive.

Return:

boolean

public isZero(): boolean source

Tests if this Integer's value equals zero.

Return:

boolean

public lessThan(other: Integer | number | string): boolean source

Tests if this Integer's value is less than the specified's.

Params:

NameTypeAttributeDescription
other Integer | number | string
  • nullable: false

Other value

Return:

boolean

public lessThanOrEqual(other: Integer | number | string): boolean source

Tests if this Integer's value is less than or equal the specified's.

Params:

NameTypeAttributeDescription
other Integer | number | string
  • nullable: false

Other value

Return:

boolean

public modulo(divisor: Integer | number | string): Integer source

Returns this Integer modulo the specified.

Params:

NameTypeAttributeDescription
divisor Integer | number | string
  • nullable: false

Divisor

Return:

Integer (nullable: false)

Remainder

public multiply(multiplier: Integer | number | string): Integer source

Returns the product of this and the specified Integer.

Params:

NameTypeAttributeDescription
multiplier Integer | number | string
  • nullable: false

Multiplier

Return:

Integer (nullable: false)

Product

public negate(): Integer source

Negates this Integer's value.

Return:

Integer (nullable: false)

Negated Integer

public not(): Integer source

Returns the bitwise NOT of this Integer.

Return:

Integer (nullable: false)

public notEquals(other: Integer | number | string): boolean source

Tests if this Integer's value differs from the specified's.

Params:

NameTypeAttributeDescription
other Integer | number | string
  • nullable: false

Other value

Return:

boolean

public or(other: Integer | number | string): Integer source

Returns the bitwise OR of this Integer and the specified.

Params:

NameTypeAttributeDescription
other Integer | number | string
  • nullable: false

Other Integer

Return:

Integer (nullable: false)

public shiftLeft(numBits: number | !Integer): Integer source

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

Params:

NameTypeAttributeDescription
numBits number | !Integer

Number of bits

Return:

Integer (nullable: false)

Shifted Integer

public shiftRight(numBits: number | !Integer): Integer source

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

Params:

NameTypeAttributeDescription
numBits number | !Integer

Number of bits

Return:

Integer (nullable: false)

Shifted Integer

public subtract(subtrahend: Integer | number | string): Integer source

Returns the difference of this and the specified Integer.

Params:

NameTypeAttributeDescription
subtrahend Integer | number | string
  • nullable: false

Subtrahend

Return:

Integer (nullable: false)

Difference

public toBigInt(): bigint source

Converts the Integer to a BigInt representation of this value

Return:

bigint

public toInt(): number source

Converts the Integer to an exact javascript Number, assuming it is a 32 bit integer.

Return:

number

public toNumber(): number source

Converts the Integer to a the nearest floating-point representation of this value (double, 53 bit mantissa).

Return:

number

public toString(radix: number=): string source

Converts the Integer to a string written in the specified radix.

Params:

NameTypeAttributeDescription
radix number=

Radix (2-36), defaults to 10

Return:

string

Throw:

RangeError

If radix is out of range

public valueOf(): bigint since 5.4.0 source

Converts the Integer to it primitive value.

Return:

bigint

See:

public xor(other: Integer | number | string): Integer source

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

Params:

NameTypeAttributeDescription
other Integer | number | string
  • nullable: false

Other Integer

Return:

Integer (nullable: false)