Options
All
  • Public
  • Public/Protected
  • All
Menu

A type for arbitrary precision, non-negative decimals.

Instances of this class are immutable.

Hierarchy

  • Decimal

Index

Accessors

  • get atomics(): string
  • get fractionalDigits(): number

Methods

  • Returns the smallest decimal >= this which has no fractional part (rounding up)

    Returns Decimal

  • Returns the greatest decimal <= this which has no fractional part (rounding down)

    Returns Decimal

  • isGreaterThanOrEqual(b: Decimal): boolean
  • isLessThanOrEqual(b: Decimal): boolean
  • a.minus(b) returns a-b.

    Both values need to have the same fractional digits. The resulting difference needs to be non-negative.

    Parameters

    Returns Decimal

  • toFloatApproximation(): number
  • Returns an approximation as a float type. Only use this if no exact calculation is required.

    Returns number

  • toString(): string
  • fromAtomics(atomics: string, fractionalDigits: number): Decimal
  • fromUserInput(input: string, fractionalDigits: number): Decimal
  • one(fractionalDigits: number): Decimal
  • Creates a Decimal with value 1.0 and the given number of fractial digits.

    Fractional digits are not relevant for the value but needed to be able to perform arithmetic operations with other decimals.

    Parameters

    • fractionalDigits: number

    Returns Decimal

  • zero(fractionalDigits: number): Decimal
  • Creates a Decimal with value 0.0 and the given number of fractial digits.

    Fractional digits are not relevant for the value but needed to be able to perform arithmetic operations with other decimals.

    Parameters

    • fractionalDigits: number

    Returns Decimal

Generated using TypeDoc