pols-utils - v5.3.11
    Preparing search index...

    Function round

    • Rounds a number to a specified number of decimal places using standard rounding rules (round half up).

      Parameters

      • value: number

        The number to round.

      • decimals: number = 0

        The number of decimal places to round to.

      Returns number

      The rounded number.

      console.log(PUtilsNumber.round(3.14159))           // 3
      console.log(PUtilsNumber.round(3.14159, 2)) // 3.14
      console.log(PUtilsNumber.round(3.1459, 2)) // 3.15
      console.log(PUtilsNumber.round(123.456789, 4)) // 123.4568