Converts a decimal to a fraction which is represented as an array of its numerator and denominator.

// Returns [-5, 4]
const fraction = Chalkboard.numb.toFraction(-1.25);
  • Parameters

    • num: number

      The decimal

    • Optionaltolerance: number = 1e-8

      The tolerance of the approximation algorithm (optional, defaults to 1e-8)

    Returns [number, number]