returns a tuple of the numerator and denominator
returns the reciprocal value
multiplies this rational with a negative 1
ensures that negative rationals have the sign in the numerator
formats this rational as decimal string
converts this rational to a float
formats this rational as string
creates a new rational from the given decimal string
const x = Rational.fromDecimal("13.37")
the decimal string
creates a new rational representing the given natural number
const x = Rational.nat(42)
the natural to represent as rational
creates a new rational with the given numerator and denominator
the numerator
the denominator
Generated using TypeDoc
A Rational number
This implementation uses bigint internally for the numerator and denominator.
A rational is immutable.
const x = Rational.of(2, 3); x.mul(Rational.nat(3)).toDecimal(); // => "2.0"