ScyllaDB University Live | Free Virtual Training Event
Learn more
ScyllaDB Documentation Logo Documentation
  • Deployments
    • Cloud
    • Server
  • Tools
    • ScyllaDB Manager
    • ScyllaDB Monitoring Stack
    • ScyllaDB Operator
  • Drivers
    • CQL Drivers
    • DynamoDB Drivers
    • Supported Driver Versions
  • Resources
    • ScyllaDB University
    • Community Forum
    • Tutorials
Install
Search Ask AI
ScyllaDB Docs ScyllaDB Node.js Driver API Reference Modules types Integer

Integer¶

types~Integer(bits, sign)

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.

Constructor¶

new 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.

Parameters:
Name Type Description
bits Array:.<number:>

Array containing the bits of the number.

sign number

The sign of the number: -1 for negative and 0 positive.

Source

types/integer.js, line 19

Deprecated

Use either Long or builtin BigInt type instead of Integer. This class will be remover at a later time.

Members¶

(static, non-null) ONE :Integer

Type:
  • Integer

Source

types/integer.js, line 757

(static, non-null) ZERO :Integer

Type:
  • Integer

Source

types/integer.js, line 754

Methods¶

abs() → {Integer}

Returns a Integer whose value is the absolute value of this

Source

types/integer.js, line 723

Returns:
Type
Integer

add(other) → (non-null) {Integer}

Returns the sum of this and the given Integer.

Parameters:
Name Type Description
other Integer

The Integer to add to this.

Source

types/integer.js, line 460

Returns:

The Integer result.

Type
Integer

and(other) → (non-null) {Integer}

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

Parameters:
Name Type Description
other Integer

The Integer to AND with this.

Source

types/integer.js, line 636

Returns:

The bitwise-AND of this and the other.

Type
Integer

compare(other) → {number}

Compares this Integer with the given one.

Parameters:
Name Type Description
other Integer

Integer to compare against.

Source

types/integer.js, line 418

Returns:

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

Type
number

divide(other) → (non-null) {Integer}

Returns this Integer divided by the given one.

Parameters:
Name Type Description
other Integer

Th Integer to divide this by.

Source

types/integer.js, line 557

Returns:

This value divided by the given one.

Type
Integer

equals(other) → {boolean}

Parameters:
Name Type Description
other Integer

Integer to compare against.

Source

types/integer.js, line 365

Returns:

Whether this Integer equals the other.

Type
boolean

getBits(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).

Parameters:
Name Type Description
index number

The index in question.

Source

types/integer.js, line 317

Returns:

The requested 32-bits as a signed number.

Type
number

getBitsUnsigned(index) → {number}

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

Parameters:
Name Type Description
index number

The index in question.

Source

types/integer.js, line 330

Returns:

The requested 32-bits as an unsigned number.

Type
number

getSign() → {number}

Source

types/integer.js, line 335

Returns:

The sign bit of this number, -1 or 0.

Type
number

greaterThan(other) → {boolean}

Parameters:
Name Type Description
other Integer

Integer to compare against.

Source

types/integer.js, line 388

Returns:

Whether this Integer is greater than the other.

Type
boolean

greaterThanOrEqual(other) → {boolean}

Parameters:
Name Type Description
other Integer

Integer to compare against.

Source

types/integer.js, line 395

Returns:

Whether this Integer is greater than or equal to the other.

Type
boolean

inspect() → {string}

Provide the name of the constructor and the string representation

Source

types/integer.js, line 716

Returns:
Type
string

isNegative() → {boolean}

Source

types/integer.js, line 351

Returns:

Whether this value is negative.

Type
boolean

isOdd() → {boolean}

Source

types/integer.js, line 355

Returns:

Whether this value is odd.

Type
boolean

isZero() → {boolean}

Source

types/integer.js, line 339

Returns:

Whether this value is zero.

Type
boolean

lessThan(other) → {boolean}

Parameters:
Name Type Description
other Integer

Integer to compare against.

Source

types/integer.js, line 402

Returns:

Whether this Integer is less than the other.

Type
boolean

lessThanOrEqual(other) → {boolean}

Parameters:
Name Type Description
other Integer

Integer to compare against.

Source

types/integer.js, line 409

Returns:

Whether this Integer is less than or equal to the other.

Type
boolean

modulo(other) → (non-null) {Integer}

Returns this Integer modulo the given one.

Parameters:
Name Type Description
other Integer

The Integer by which to mod.

Source

types/integer.js, line 619

Returns:

This value modulo the given one.

Type
Integer

multiply(other) → (non-null) {Integer}

Returns the product of this and the given Integer.

Parameters:
Name Type Description
other Integer

The Integer to multiply against this.

Source

types/integer.js, line 494

Returns:

The product of this and the other.

Type
Integer

negate() → (non-null) {Integer}

Source

types/integer.js, line 452

Returns:

The negation of this value.

Type
Integer

not() → (non-null) {Integer}

Source

types/integer.js, line 623

Returns:

The bitwise-NOT of this value.

Type
Integer

notEquals(other) → {boolean}

Parameters:
Name Type Description
other Integer

Integer to compare against.

Source

types/integer.js, line 381

Returns:

Whether this Integer does not equal the other.

Type
boolean

or(other) → (non-null) {Integer}

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

Parameters:
Name Type Description
other Integer

The Integer to OR with this.

Source

types/integer.js, line 649

Returns:

The bitwise-OR of this and the other.

Type
Integer

shiftLeft(numBits) → (non-null) {Integer}

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

Parameters:
Name Type Description
numBits number

The number of bits by which to shift.

Source

types/integer.js, line 675

Returns:

This shifted to the left by the given amount.

Type
Integer

shiftRight(numBits) → (non-null) {Integer}

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

Parameters:
Name Type Description
numBits number

The number of bits by which to shift.

Source

types/integer.js, line 696

Returns:

This shifted to the right by the given amount.

Type
Integer

shorten(numBits) → (non-null) {Integer}

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

Parameters:
Name Type Description
numBits number

The number of bits by which to shift.

Source

types/integer.js, line 433

Returns:

The shorted integer value.

Type
Integer

subtract(other) → (non-null) {Integer}

Returns the difference of this and the given Integer.

Parameters:
Name Type Description
other Integer

The Integer to subtract from this.

Source

types/integer.js, line 486

Returns:

The Integer result.

Type
Integer

toInt() → {number}

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

Source

types/integer.js, line 257

Returns:

The corresponding int value.

Type
number

toJSON()

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

Source

types/integer.js, line 730

toNumber() → {number}

Source

types/integer.js, line 261

Returns:

The closest floating-point representation to this value.

Type
number

toString(optRadixopt) → {string}

Parameters:
Name Type Attributes Description
optRadix number <optional>

The radix in which the text should be written.

Source

types/integer.js, line 278

Returns:

The textual representation of this value.

Type
string

xor(other) → (non-null) {Integer}

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

Parameters:
Name Type Description
other Integer

The Integer to XOR with this.

Source

types/integer.js, line 662

Returns:

The bitwise-XOR of this and the other.

Type
Integer

(static) fromBits(bits) → (non-null) {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:
Name Type Description
bits Array:.<number:>

The bits of the number, in 32-bit signed pieces, in little-endian order.

Source

types/integer.js, line 102

Returns:

The corresponding Integer value.

Type
Integer

(static) fromBuffer(buf) → {Integer}

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

Parameters:
Name Type Description
buf Buffer

Source

types/integer.js, line 154

Returns:
Type
Integer

(static) fromInt(value) → (non-null) {Integer}

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

Parameters:
Name Type Description
value number

A 32-bit integer value.

Source

types/integer.js, line 59

Returns:

The corresponding Integer value.

Type
Integer

(static) fromNumber(value) → (non-null) {Integer}

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

Parameters:
Name Type Description
value number

The value in question.

Source

types/integer.js, line 79

Returns:

The corresponding Integer value.

Type
Integer

(static) fromString(str, optRadixopt) → (non-null) {Integer}

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

Parameters:
Name Type Attributes Description
str string

The textual representation of the Integer.

optRadix number <optional>

The radix in which the text is written.

Source

types/integer.js, line 114

Returns:

The corresponding Integer value.

Type
Integer

(static) toBuffer(value) → {Buffer}

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'

Parameters:
Name Type Description
value Integer

Source

types/integer.js, line 192

Returns:
Type
Buffer

Was this page helpful?

PREVIOUS
InetAddress
NEXT
LocalDate
  • Create an issue
  • Edit this page

On this page

  • Integer
    • Constructor
    • Members
    • Methods
ScyllaDB Node.js Driver
Search Ask AI
  • main
    • main
  • API Reference
    • Modules
      • auth
        • AuthProvider
        • Authenticator
        • PlainTextAuthProvider
      • concurrent
      • datastax
      • errors
        • ArgumentError
        • AuthenticationError
        • BusyConnectionError
        • DriverInternalError
        • NoHostAvailableError
        • NotSupportedError
        • OperationTimedOutError
        • ResponseError
      • geometry
      • mapping
        • DefaultTableMappings
        • Mapper
        • ModelBatchItem
        • ModelMapper
        • Result
        • UnderscoreCqlToCamelCaseMappings
        • TableMappings
      • metadata
        • Aggregate
        • ClientState
        • ColumnMetadata
        • Index
        • KeyspaceMetadata
        • MaterializedView
        • Metadata
        • SchemaFunction
        • Strategy
        • TableMetadata
        • UdtField
        • UserDefinedType
      • metrics
        • DefaultMetrics
        • ClientMetrics
      • policies
        • addressResolution
          • AddressTranslator
          • EC2MultiRegionTranslator
          • MappingAddressTranslator
        • loadBalancing
          • AllowListPolicy
          • DCAwareRoundRobinPolicy
          • DefaultLoadBalancingPolicy
          • LegacyDefaultLoadBalancingPolicy
          • LoadBalancingConfig
          • LoadBalancingPolicy
          • RoundRobinPolicy
          • TokenAwarePolicy
        • reconnection
          • ConstantReconnectionPolicy
          • ExponentialReconnectionPolicy
          • ReconnectionPolicy
        • retry
          • FallthroughRetryPolicy
          • RetryPolicy
        • speculativeExecution
          • ConstantSpeculativeExecutionPolicy
          • NoSpeculativeExecutionPolicy
          • SpeculativeExecutionPolicy
        • timestampGeneration
          • MonotonicTimestampGenerator
          • TimestampGenerator
      • tracker
        • RequestLogger
        • RequestTracker
      • types
        • Duration
        • InetAddress
        • Integer
        • LocalDate
        • Long
        • ResultSet
        • ResultStream
        • Row
        • TimeUuid
        • Vector
    • Classes
      • AddressResolver
      • ByteOrderedToken
      • Client
      • Encoder
      • EncoderMembers
      • ExecutionOptions
      • ExecutionProfile
      • FrameReader
      • HashSet
      • Host
      • HostMap
      • LineString
      • Murmur3Token
      • Point
      • Polygon
      • PreparedInfo
      • RandomToken
      • SslOptions
      • Token
      • TokenRange
    • Interfaces
    • Events
    • Global Functions and Constants
Docs Tutorials University Contact Us About Us
© 2026 ScyllaDB | Terms of Service | Privacy Policy | ScyllaDB, and ScyllaDB Cloud, are registered trademarks of ScyllaDB, Inc.
Last updated on 14 May 2026.
Powered by Sphinx 9.1.0 & ScyllaDB Theme 1.9.2