round
mathComputes number rounded to precision.
Signature
round(number: number, precision?: number): numberParameters
| Name | Type | Description |
|---|---|---|
number | number | The number to round |
precision? | number | The precision to round toDefault: 0 |
Returns
number - Returns the rounded number
Examples
Round to integer
import { round } from 'dashlite'
const result = round(4.006)
console.log(result)Output:
4Round with precision
import { round } from 'dashlite'
const result = round(4.006, 2)
console.log(result)Output:
4.01Negative precision
import { round } from 'dashlite'
const result = round(4060, -2)
console.log(result)Output:
4100Available since version 1.0.0