Fraction

The base class which all subsequent fraction classes extend. Not meant to be used directly.

Constructor

constructor(numerator: BigintIsh, denominator: BigintIsh = ONE)

Properties

  • numerator (JSBI type)

  • denominator (JSBI type)

Methods

quotient

Performs floor division.

quotient(): JSBI

remainder

Gets the remainder after floor division.

remainder(): Fraction

invert

invert(): Fraction

add

add(other: Fraction | BigintIsh): Fraction

subtract

subtract(other: Fraction | BigintIsh): Fraction

lessThan

lessThan(other: Fraction | BigintIsh): boolean

equalTo

equalTo(other: Fraction | BigintIsh): boolean

greaterThan

greaterThan(other: Fraction | BigintIsh): boolean

multiply

multiply(other: Fraction | BigintIsh): Fraction

divide

divide(other: Fraction | BigintIsh): Fraction

toSignificant

Formats a fraction to the specified number of significant digits.

toSignificant(
    significantDigits: number,
    format: object = { groupSeparator: '' },
    rounding: Rounding = Rounding.ROUND_HALF_UP
  ): string

toFixed

Formats a fraction to the specified number of decimal places.

toFixed(
    decimalPlaces: number,
    format: object = { groupSeparator: '' },
    rounding: Rounding = Rounding.ROUND_HALF_UP
  ): string

Last updated