Function round

  • Round a given number with a given precision. Shifts with exponential notation to avoid floating-point issues.

    Parameters

    • number: number

      the number to round.

    • precision: number = 0

      the number of decimal points.

    Returns number

    The rounded number.

    Throws

    if the given number is not finite or NaN.

    Example

    round(1.2345, 2);
    //=> 1.23
    round(1.2345);
    //=> 1

Generated using TypeDoc