Options
All
• Public
• Public/Protected
• All

# Class Fraction

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

• Fraction

## Constructors

### constructor

• new Fraction(numerator?: number, denominator?: number, wholeValue?: number, simplify?: boolean): Fraction
• #### Parameters

• ##### Default value wholeValue: number = 0

the integer number, needed for values greater than 1

• ##### Default value simplify: boolean = true

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

## Properties

### Private denominator

denominator: number = 1

### Private numerator

numerator: number = 0

### Private realValue

realValue: number

### Private wholeValue

wholeValue: number = 0

### Static FloatInaccuracyTolerance

FloatInaccuracyTolerance: number = 0.0001

### StaticPrivate maximumAllowedNumber

maximumAllowedNumber: number = 46340

## Accessors

### Denominator

• get Denominator(): number
• set Denominator(value: number): void

### Numerator

• get Numerator(): number
• set Numerator(value: number): void

### RealValue

• get RealValue(): number

### WholeValue

• 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.

### GetExpandedNumerator

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

### IsNegative

• IsNegative(): boolean

### Quantize

• Quantize(maxAllowedDenominator: number): Fraction
• Brute Force quanization by searching incremental with the numerator until the denominator is smaller/equal than the desired one.

### Sub

• 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.

### distanceFromBeat

• distanceFromBeat(timeSignature: Fraction): number

### expand

• expand(expansionValue: number): void

### isOnBeat

• isOnBeat(timeSignature: Fraction): boolean

### Private setRealValue

• setRealValue(): void

### Private simplify

• simplify(): void

### toString

• toString(): string

### Static createFromFraction

• The same as Fraction.clone

### StaticPrivate greatestCommonDenominator

• greatestCommonDenominator(a: number, b: number): number

### Static max

• Returns the maximum of two fractions (does not clone)

### Static plus

#### Returns Fraction

Generated using TypeDoc