Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Hierarchy

  • Fraction

Index

Constructors

  • new Fraction(numerator?: number, denominator?: number, wholeValue?: number, simplify?: boolean): Fraction
  • 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

denominator: number = 1
numerator: number = 0
realValue: number
wholeValue: number = 0
FloatInaccuracyTolerance: number = 0.0001
maximumAllowedNumber: number = 46340

Accessors

  • get Denominator(): number
  • set Denominator(value: number): void
  • get Numerator(): number
  • set Numerator(value: number): void
  • get RealValue(): number
  • get WholeValue(): number
  • set WholeValue(value: number): void

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

    • fraction: Fraction

      the Fraction to add.

    Returns Fraction

  • GetExpandedNumerator(): number
  • Returns the unified numerator where the whole value will be expanded with the denominator and added to the existing numerator.

    Returns number

  • IsNegative(): boolean
  • Quantize(maxAllowedDenominator: number): Fraction
  • 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

  • calculateNumberOfNeededDots(): number
  • distanceFromBeat(timeSignature: Fraction): number
  • expand(expansionValue: number): void
  • isOnBeat(timeSignature: Fraction): boolean
  • setRealValue(): void
  • simplify(): void
  • toString(): string
  • greatestCommonDenominator(a: number, b: number): number

Generated using TypeDoc