Function alignScale

  • Aligns the scale(decimal places) of two Big instances before performing arithmetic operations. It takes two Big instances as input and returns a tuple (array) of two new Big instances with the same scale.

    When the scales of the two input instances are different, the function adjusts the value and scale of one of the instances so that their scales are equal, allowing the arithmetic operations to be performed correctly.

    Note: This function does not modify the input instances. It creates new instances with the aligned scales.

    Parameters

    • a: Big

      The first Big instance.

    • b: Big

      The second Big instance.

    • Optional mutable: boolean = false

      Whether to mutate the both Big instances. Defaults to false.

    Returns [Big, Big]

    A tuple of two Big instances with the same scale.

    Example

    const a = new Big(123.456);
    const b = new Big(123.456789);
    const [x, y] = alignScale(a, b);
    console.log(x.toString()); // "123.456000"
    console.log(y.toString()); // "123.456789"

Generated using TypeDoc