Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Fraction

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

Hierarchy

  • Fraction

Index

Constructors

constructor

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

    • Default value numerator: number = 0
    • Default value denominator: number = 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.

    Returns Fraction

Properties

Private denominator

denominator: number = 1

Private numerator

numerator: number = 0

Private realValue

realValue: number

Static Private 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

Methods

Add

CompareTo

Equals

GetInversion

Quantize

  • Quantize(maxAllowedDenominator: number): Fraction

Sub

clone

lt

lte

multiplyDenominatorWithFactor

  • multiplyDenominatorWithFactor(factor: number): void

multiplyWithFactor

  • multiplyWithFactor(factor: number): void

Private setRealValue

  • setRealValue(): void

Private simplify

  • simplify(): void

toString

  • toString(): string

Static Equal

Static createFromFraction

Static Private greatestCommonDenominator

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

Static max

Static minus

Static plus

Generated using TypeDoc