round es-toolkit
Rounds a number to a specified number of decimal places.
Usage
round(value, precision?)
Use round when you want to round a number to a specific number of decimal places. It's a mathematical function for precise calculations.
Useful in price calculations and statistics.
Round in calculations where accuracy matters.
Invalid precision values throw an error.
Parameters
valuenumberrequired
The number to round.
precisionnumberoptional
The number of decimal places. Must be an integer. Defaults to 0.
Returns
Returns the number rounded to the specified precision.
Throws
- Throws an error if
precisionis not an integer.
Source: es-toolkit
Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.