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).
places
import * as N from "flurp/number";const toTwoPlaces = N.round(2);toTwoPlaces(12345.6789); // 12345.68const toInteger = N.round(0);toInteger(12345.6789)); // 12346const toHundreds = N.round(-2);toHundreds(12345.6789); // 12300
Rounds to a number of
places
right of the decimal point. Rounds to the nearest integer ifplaces
is zero. Negativeplaces
rounds to the left of the decimal point, e.g.,places
of -3 rounds to the nearest thousand (10^3).Example