Skip to main content
Latest
class Bson.Long
import { Bson } from "https://deno.land/x/exodus@0.1.8/deps.ts";
const { Long } = Bson;

A class representing a 64-bit integer

Constructors

new
Long(
low?: number,
high?: number,
unsigned?: boolean,
)

Constructs a 64 bit two's-complement integer, given its low and high 32 bit values as signed integers. See the from* functions below for more convenient ways of constructing Longs.

Properties

__isLong__: true

An indicator used to reliably determine if an object is a Long or not.

_bsontype: "Long"
comp: (other:
| string
| number
| Long
) => 0 | 1 | -1

This is an alias of Long.compare

div: (divisor:
| string
| number
| Long
) => Long

This is an alias of Long.divide

eq: (other:
| string
| number
| Long
) => boolean

This is an alias of Long.equals

eqz: () => boolean

This is an alias of Long.isZero

ge: (other:
| string
| number
| Long
) => boolean

This is an alias of Long.greaterThanOrEqual

gt: (other:
| string
| number
| Long
) => boolean

This is an alias of Long.greaterThan

gte: (other:
| string
| number
| Long
) => boolean

This is an alias of Long.greaterThanOrEqual

high: number

The high 32 bits as a signed value.

le: (other:
| string
| number
| Long
) => boolean

This is an alias of Long.lessThanOrEqual

low: number

The low 32 bits as a signed value.

lt: (other:
| string
| number
| Long
) => boolean

This is an alias of Long#lessThan.

lte: (other:
| string
| number
| Long
) => boolean

This is an alias of Long.lessThanOrEqual

mod: (divisor:
| string
| number
| Long
) => Long

This is an alias of Long.modulo

mul: (multiplier:
| string
| number
| Long
) => Long

This is an alias of Long.multiply

ne: (other:
| string
| number
| Long
) => boolean

This is an alias of Long.notEquals

neg: () => Long

This is an alias of Long.negate

neq: (other:
| string
| number
| Long
) => boolean

This is an alias of Long.notEquals

rem: (divisor:
| string
| number
| Long
) => Long

This is an alias of Long.modulo

shl: (numBits: number | Long) => Long

This is an alias of Long.shiftLeft

shr: (numBits: number | Long) => Long

This is an alias of Long.shiftRight

shr_u: (numBits: Long | number) => Long

This is an alias of Long.shiftRightUnsigned

shru: (numBits: Long | number) => Long

This is an alias of Long.shiftRightUnsigned

sub: (subtrahend:
| string
| number
| Long
) => Long

This is an alias of Long.subtract

unsigned: boolean

Whether unsigned or not.

Methods

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

Returns the sum of this and the specified Long.

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

Returns the sum of this and the specified Long.

compare(other:
| string
| number
| Long
): 0 | 1 | -1

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

divide(divisor:
| string
| number
| Long
): Long

Returns this Long divided by the specified. The result is signed if this Long is signed or unsigned if this Long is unsigned.

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

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

getHighBits(): number

Gets the high 32 bits as a signed integer.

Gets the high 32 bits as an unsigned integer.

getLowBits(): number

Gets the low 32 bits as a signed integer.

Gets the low 32 bits as an unsigned integer.

getNumBitsAbs(): number

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

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

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

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

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

isEven(): boolean

Tests if this Long's value is even.

isNegative(): boolean

Tests if this Long's value is negative.

isOdd(): boolean

Tests if this Long's value is odd.

isPositive(): boolean

Tests if this Long's value is positive.

isZero(): boolean

Tests if this Long's value equals zero.

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

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

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

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

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

Returns this Long modulo the specified.

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

Returns the product of this and the specified Long.

Returns the Negation of this Long's value.

Returns the bitwise NOT of this Long.

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

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

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

Returns the bitwise OR of this Long and the specified.

shiftLeft(numBits: number | Long): Long

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

shiftRight(numBits: number | Long): Long

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

shiftRightUnsigned(numBits: Long | number): Long

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

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

Returns the difference of this and the specified Long.

toBigInt(): bigint

Converts the Long to a BigInt (arbitrary precision).

toBytes(le?: boolean): number[]

Converts this Long to its byte representation.

toBytesBE(): number[]

Converts this Long to its big endian byte representation.

toBytesLE(): number[]

Converts this Long to its little endian byte representation.

toInt(): number

Converts the Long to a 32 bit integer, assuming it is a 32 bit integer.

toNumber(): number

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

Converts this Long to signed.

toString(radix?: number): string

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

Converts this Long to unsigned.

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

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

Static Properties

MAX_UNSIGNED_VALUE: Long

Maximum unsigned value.

MAX_VALUE: Long

Maximum signed value.

MIN_VALUE: Long

Minimum signed value.

NEG_ONE: Long

Signed negative one.

ONE: Long

Signed one.

TWO_PWR_24: Long
UONE: Long

Unsigned one.

UZERO: Long

Unsigned zero.

ZERO: Long

Signed zero

Static Methods

fromBigInt(value: bigint, unsigned?: boolean): Long

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

fromBits(
lowBits: number,
highBits: number,
unsigned?: boolean,
): Long

Returns a Long representing the 64 bit integer that comes by concatenating the given low and high bits. Each is assumed to use 32 bits.

fromBytes(
bytes: number[],
unsigned?: boolean,
le?: boolean,
): Long

Creates a Long from its byte representation.

fromBytesBE(bytes: number[], unsigned?: boolean): Long

Creates a Long from its big endian byte representation.

fromBytesLE(bytes: number[], unsigned?: boolean): Long

Creates a Long from its little endian byte representation.

fromExtendedJSON(doc: { $numberLong: string; }, options?: EJSONOptions): number | Long
fromInt(value: number, unsigned?: boolean): Long

Returns a Long representing the given 32 bit integer value.

fromNumber(value: number, unsigned?: boolean): Long

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

fromString(
str: string,
unsigned?: boolean,
radix?: number,
): Long

Returns a Long representation of the given string, written using the specified radix.

fromValue(val: number | string | { low: number; high: number; unsigned?: boolean; }, unsigned?: boolean): Long

Converts the specified value to a Long.

isLong(value: unknown): value is Long

Tests if the specified object is a Long.