Skip to Content
utilsround

round

See source on Github 

The round function rounds a number to a given precision. Positive precision rounds to decimal places, negative precision rounds to powers of ten, and the default precision rounds to the nearest integer.

  • @param number - The number to round.
  • @param precision - The precision to round to. Defaults to 0.
  • @returns The rounded number.

Example

round(4.006) // 4 round(4.006, 2) // 4.01 round(4060, -2) // 4100