@jossmac/lil-libs
    Preparing search index...

    Function roundToPrecision

    • Rounds a number to a fixed number of decimal places.

      When digits <= 0, rounds to the nearest integer. The base parameter defaults to 10; most callers should leave it unchanged.

      • value: number

        Number to round.

      • digits: number

        Fractional digits to keep; values <= 0 delegate to Math.round.

      • base: number = 10

        Radix used for scaling (default 10); most callers should leave this unchanged.

      value rounded to digits decimal places at the given base.

      roundToPrecision(3.14159, 2); // 3.14
      roundToPrecision(3.005, 2); // 3.01
      roundToPrecision(3.7, 0); // 4