Function round

  • Rounds to a number of places right of the decimal point. Rounds to the nearest integer if places is zero. Negative places rounds to the left of the decimal point, e.g., places of -3 rounds to the nearest thousand (10^3).

    Example

    import * as N from "flurp/number";

    const toTwoPlaces = N.round(2);
    toTwoPlaces(12345.6789); // 12345.68

    const toInteger = N.round(0);
    toInteger(12345.6789)); // 12346

    const toHundreds = N.round(-2);
    toHundreds(12345.6789); // 12300

    Parameters

    • places: number = 0

    Returns ((x: number) => number)

      • (x: number): number
      • Parameters

        • x: number

        Returns number