A type for arbitrary precision, non-negative decimals.

Instances of this class are immutable.

Accessors

  • get atomics(): string
  • Returns string

  • get fractionalDigits(): number
  • Returns number

Methods

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

    Returns Decimal

  • Parameters

    Returns boolean

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

    Returns Decimal

  • Parameters

    Returns boolean

  • Parameters

    Returns boolean

  • Parameters

    Returns boolean

  • Parameters

    Returns 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

  • a.multiply(b) returns a*b.

    We only allow multiplication by unsigned integers to avoid rounding errors.

    Parameters

    Returns Decimal

  • a.plus(b) returns a+b.

    Both values need to have the same fractional digits.

    Parameters

    Returns Decimal

  • Returns an approximation as a float type. Only use this if no exact calculation is required.

    Returns number

  • Returns string

  • Parameters

    Returns number

  • Parameters

    • atomics: string
    • fractionalDigits: number

    Returns Decimal

  • Parameters

    • input: string
    • fractionalDigits: number

    Returns 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

  • 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