Skip to content

Latest commit

 

History

History
153 lines (98 loc) · 1.7 KB

File metadata and controls

153 lines (98 loc) · 1.7 KB

API Reference

Int

Constructor

Int(value: number | string | Int): Int

Create arbitrary precision integer.

Example:

Int(42)
Int("99999999999999")
Int(anotherInt)

Arithmetic Operations

.add(other)

add(other: number | string | Int): Int

.subtract(other)

subtract(other: number | string | Int): Int

.multiply(other)

multiply(other: number | string | Int): Int

.divide(other)

divide(other: number | string | Int): Int

Integer division (truncates decimal).

.mod(other)

mod(other: number | string | Int): Int

.negate()

negate(): Int

.abs()

abs(): Int

Comparison Methods

.equals(other)

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

.gt(other) / .gte(other)

gt(other: number | string | Int): boolean
gte(other: number | string | Int): boolean

.lt(other) / .lte(other)

lt(other: number | string | Int): boolean
lte(other: number | string | Int): boolean

Conversion Methods

.toString()

toString(): string

.toNumber()

toNumber(): number

⚠️ May lose precision for large numbers.


Decimal

Constructor

Decimal(value: number | string | Decimal): Decimal

Create precise decimal number.

Example:

Decimal("0.1")
Decimal(3.14)
Decimal(anotherDecimal)

Arithmetic Operations

Same as Int, plus:

.round(decimalPlaces)

round(decimalPlaces: number): Decimal

Example:

Decimal("3.14159").round(2).toString()  // "3.14"

Comparison & Conversion

Same methods as Int.