@pbroom/color-kitUtilities

round

Round value to decimals decimal places with Math.round (halves round up). Subject to binary float representation, so round(1.005, 2) is 1.

functionimport { round } from '@pbroom/color-kit';index.ts:42
function round(  value: number, ,  decimals?: number,): number;

Parameters

valuenumber
Number to round
decimals?numberdefault 0
Decimal places to keep (default 0)

Returns

numberThe rounded number

Example

TypeScript
import { round } from '@pbroom/color-kit';

round(0.62308, 3); // → 0.623
round(59.6); // → 60