@tempots/std
roundTo() function
Rounds a number to the specified number of decimals.
Signature:
roundTo: (f: number, decimals: number) => number
Parameters
Parameter |
Type |
Description |
---|---|---|
f |
number |
The number to round. |
decimals |
number |
The number of decimals to round to. |
Returns: number
The rounded number.
Example
roundTo(1.234, 2) // returns 1.23
roundTo(1.234, 1) // returns 1.2
roundTo(1.234, 0) // returns 1