Function divBig

  • Divides two Big instances and returns the result as a new Big instance.

    Parameters

    • dividend: Big

      The dividend Big instance.

    • divisor: Big

      The divisor Big instance.

    • Optional precision: number = DEFAULT_PRECISION

      The number of decimal places to keep in the result (optional). Defaults to the maximum scale of both Big instances. If the precision is lower than the scale of the result, the result will be rounded. If input numbers are without scale, the precision will be 0, so the result will be rounded to an integer.

    • Optional roundingMode: RoundingMode = "half-up"

      The rounding mode to apply ("half-up", "down" or "up"). Defaults to "half-up".

    • Optional mutable: boolean = false

      Whether to mutate the dividend or not. Defaults to false.

    Returns Big

    • A new Big instance representing the result of the division.

    Throws

    Division by zero is not allowed.

    Example

    const big1 = new Big(10);
    const big2 = new Big(3);
    console.log(divBig(big1, big2).toString()); // "3.33333333333333333333"
    console.log(divBig(big1, big2, 0).toString()); // "3"
    console.log(divBig(big1, big2, 2).toString()); // "3.33"
    console.log(divBig(big1, big2, 2, "down").toString()); // "3.33"
    console.log(divBig(big1, big2, 2, "up").toString()); // "3.34"

Generated using TypeDoc