Syntax

TypeScript
import { round } from '@opentf/std';

round(n: number, decimals?: number): number;

Parameters

NameTypeDescription
nnumberThe number to round.
decimalsnumberThe number of decimal places (default 0).

Returns

The rounded number without floating point drift.

decimals must be a finite integer between -308 and 308.

Examples

TypeScript
round(1.005, 2) //=> 1.01
round(1.23456, 3) //=> 1.235
Last updated on
Edit this page