SheetXL - v0.3.20
    Preparing search index...

    Variable roundAccuratelyConst

    roundAccurately: (number: number, decimalPlaces?: number) => number

    Rounds a number to a specified number of decimal places, ensuring precision is maintained. If no decimal places are provided, the default is 0 (rounds to the nearest integer).

    This function uses scientific notation to avoid movable-point precision errors commonly associated with rounding in JavaScript.

    Type declaration

      • (number: number, decimalPlaces?: number): number
      • Parameters

        • number: number

          The number to round. If the number is null or not finite (e.g., Infinity), null is returned.

        • OptionaldecimalPlaces: number

          The number of decimal places to round to (default is 0).

        Returns number

        The rounded number, or null if the input is invalid.

    roundAccurately(123.4567, 2); // 123.46
    roundAccurately(123.4567); // 123
    roundAccurately(123.4567, 0); // 123
    roundAccurately(null); // null
    roundAccurately(Infinity); // null