Chalkboard - v3.0.1
    Preparing search index...

    Function toFraction

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

      Parameters

      • num: number

        The decimal number

      • Optionaltolerance: number = 1e-8

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

      Returns [number, number]

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