@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
| Parameter | Type | Description |
|---|---|---|
input | number | The number to round. |
options | RoundOptions | Optional 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