Function: roundTo()
roundTo(
value,decimals?):number
Defined in: math.ts:17
Rounds a number to a given number of decimal places.
Parameters
value
number
The number to round.
decimals?
number = 0
The number of decimal places to round to. Defaults to 0.
Returns
number
The rounded number.
Example
ts
roundTo(3.14159) // 3 (rounds to integer by default)
roundTo(3.14159, 2) // 3.14
roundTo(3.14159, 4) // 3.1416
roundTo(1234.5, -2) // 1200 (negative decimals round to tens, hundreds, etc.)