OpenSheetMusicDisplay
    Preparing search index...

    Class Fraction

    A class representing mathematical fractions, which have a numerator and a denominator.

    Index

    Constructors

    • Parameters

      • numerator: number = 0
      • denominator: number = 1
      • wholeValue: number = 0

        the integer number, needed for values greater than 1

      • simplify: boolean = true

        If simplify is true, then the fraction is simplified to make both the numerator and denominator coprime, and less than maximumAllowedNumber.

      Returns Fraction

    Properties

    FloatInaccuracyTolerance: number = 0.0001

    Accessors

    Methods

    • Adds a Fraction to this Fraction. Attention: This changes the already existing Fraction, which might be referenced elsewhere! Use Fraction.plus() for creating a new Fraction object being the sum of two Fractions.

      Parameters

      Returns Fraction

    • Returns the unified numerator where the whole value will be expanded with the denominator and added to the existing numerator.

      Returns number

    • Brute Force quanization by searching incremental with the numerator until the denominator is smaller/equal than the desired one.

      Parameters

      • maxAllowedDenominator: number

      Returns Fraction

    • Subtracts a Fraction from this Fraction. Attention: This changes the already existing Fraction, which might be referenced elsewhere! Use Fraction.minus() for creating a new Fraction object being the difference of two Fractions.

      Parameters

      • fraction: Fraction

        the Fraction to subtract.

      Returns Fraction