Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Fraction

A fraction with a numerator and a denominator.

Hierarchy

  • Fraction

Index

Constructors

Methods

Constructors

constructor

  • new Fraction(numerator: number, denominator: number): Fraction
  • Creates and immediately reduce the fraction using the greatest common divider of the numerator and denominator.

    Parameters

    • numerator: number

      The numerator of this fraction.

    • denominator: number

      The denominator of this fraction.

    Returns Fraction

Methods

add

  • Return a new fraction by adding the given fraction to this fraction.

    Parameters

    • other: Fraction

      The fraction to add to this one.

    Returns Fraction

    A new fraction obtained by adding the 2 fractions.

sameAs

  • Checks if this fraction is equal to the provided fraction.

    Parameters

    • other: Fraction

      The fraction to compare to.

    Returns boolean

    true if the 2 fractions are equal, false else.

valueOf

  • valueOf(): number
  • Returns the number value of this fraction.

    Returns number

    The number value of this fraction

Generated using TypeDoc