Skip to content

@technobuddha > library > Math > Operations

Function: round()

ts
function round(input: number, options: RoundOptions): number;

Defined in: round.ts:30

Returns the nearest integer to the given number, with optional precision adjustments.

Parameters

ParameterTypeDescription
inputnumberThe number to round.
optionsRoundOptionsOptional configuration object.

Returns

number

The nearest integer to the adjusted input.

Example

typescript
round(2.3); // 2
round(2.7); // 3
round(-2.5); // -2
round(2.345, { precision: 2 }); // 2.35
round(-2.345, { precision: 2 }); // -2.35