Hierarchy

  • Fraction

Constructors

Properties

Methods

Constructors

Properties

denominator: number
numerator: number

Methods

  • Creates a new Fraction object from an integral number.

    Parameters

    • numberValue: number

      The number to convert to a fraction.

    Returns Fraction

    A new Fraction object representing the number as a fraction.

    Example

    const fraction = Fraction.fromIntegral(1.75);
    console.log(fraction.numerator, fraction.denominator); // Output: 7 4
  • Converts the fraction to an integral number.

    Parameters

    Returns number

    The integral value of the fraction.

    Example

    const fraction = new Fraction(5, 2);
    const integral = fraction.toIntergral();
    console.log(integral); // Output: 2.5

Generated using TypeDoc