The QQ class represents a rational number, ℚ.

The QQ implementation is that of an immutable (value) type.

The numerator and denominator are reduced to their lowest form.

Construct new instances using the static valueOf method.

Accessors

  • get denom(): number
  • The denominator of the rational number.

    Returns number

  • get numer(): number
  • The numerator of the rational number.

    Returns number

Methods

  • Parameters

    Returns QQ

    this + rhs

  • Parameters

    Returns QQ

    this / rhs

  • Determines whether two rational numbers are equal.

    Parameters

    Returns boolean

    true if this rational number equals the other rational number.

  • Returns number

    37 * numerator + 13 * denominator

  • Computes the multiplicative inverse of this rational number.

    Returns QQ

    1 / this

  • Returns boolean

    true if this rational number is one (1), otherwise false.

  • Returns boolean

    true if this rational number is zero (0), otherwise false.

  • Parameters

    Returns QQ

    this * rhs

  • Computes the additive inverse of this rational number.

    Returns QQ

    -this

  • Parameters

    Returns QQ

    this - rhs

  • Computes a non-normative string representation of this rational.

    Parameters

    • Optional radix: number

    Returns string

  • Parameters

    • n: number
    • d: number

    Returns QQ

    The rational number numer / denom reduced to its lowest form.

Generated using TypeDoc