Class Currency

Currency represents a local currency amount that can be formatted using the Intl apis.

Hierarchy

Constructors

Properties

PRECISION: number = 20

Accessors

  • get precision(): number
  • Returns number

  • set precision(value: number): void
  • Parameters

    • value: number

    Returns void

Methods

  • Returns a new Decimal that is the sum of this and x.

    Example

    let a = decimal('50000000000')
    let b = decimal('0.000000005')
    a.add(b) // 50000000000.000000005

    Returns

    Parameters

    • x: any

    Returns Currency

  • Returns a comparison value representing the ordering of this value in respect to x.

    • -1 if this < x
    • 1 if this > x
    • 0 if this == x

    Returns

    Parameters

    • x: any

    Returns 1 | -1 | 0

  • Returns a new Decimal that is the quotient of this and x

    Example

    let a = decimal('1')
    let b = decimal('3')
    a.div(b) // 0.333333333333333333333333333333

    Returns

    Parameters

    • x: any

    Returns Currency

  • Returns true if this value is equal to the value of x, otherwise false.

    Returns

    Parameters

    • x: any

      other

    Returns any

  • Parameters

    • opts: NumberFormatOptions = {}
    • Optional locale: string

    Returns string

  • Returns true if this value is greater than the value of x, otherwise false.

    Returns

    Parameters

    • x: any

    Returns boolean

  • Returns true if this value is greater than or equal to the value of x, otherwise false.

    Returns

    Parameters

    • x: any

    Returns boolean

  • Returns true if this value is less than the value of x, otherwise false.

    Returns

    Parameters

    • x: any

    Returns boolean

  • Returns true if this value is less than or equal to the value of x, otherwise false.

    Returns

    Parameters

    • x: any

    Returns boolean

  • Returns a new Decimal that is the product of this and x.

    Example

    let a = decimal('0.0000000000000000000025')
    let b = decimal('400000000000000000000')
    a.mul(b) // 1

    Returns

    Parameters

    • x: any

    Returns Currency

  • Parameters

    • Optional digits: number

    Returns string

  • Returns a new Decimal that is the difference between this and x.

    Example

    let a = decimal('1')
    let b = decimal('0.0000000000000000001')
    a.sub(b) // 0.9999999999999999999

    Returns

    Parameters

    • x: any

    Returns Currency

Generated using TypeDoc