API Reference@grafana/dataroundDecimals

roundDecimals() function

roundDecimals() function

Round half away from zero (‘commercial’ rounding) Uses correction to offset floating-point inaccuracies. Works symmetrically for positive and negative numbers.

ref: https://stackoverflow.com/a/48764436

Signature

export declare function roundDecimals(val: number, dec?: number): number;

Import

import { roundDecimals } from '@grafana/data';

Parameters

ParameterTypeDescription
valnumber
decnumber

Returns:

number