round

math

Computes number rounded to precision.

Signature

round(number: number, precision?: number): number

Parameters

NameTypeDescription
numbernumberThe number to round
precision?numberThe 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:

4

Round with precision

import { round } from 'dashlite'

const result = round(4.006, 2)
console.log(result)

Output:

4.01

Negative precision

import { round } from 'dashlite'

const result = round(4060, -2)
console.log(result)

Output:

4100

Available since version 1.0.0