Skip to content

Function: roundToEven() ​

ts
function roundToEven(value, precision): number;

Defined in: roundToEven.ts:14

Rounds a value with the procedure from step 2 of the "Serializing a Decimal" specification. The style is known as "even rounding", "banker's rounding", or "commercial rounding".

Parameters ​

value ​

number

The value to round

precision ​

number

The number of decimal places to round to

Returns ​

number

The rounded value

Example ​

ts
equal(roundToEven(1.0025, 3), 1.002)
equal(roundToEven(1.0035, 3), 1.004)

A Streaming Video Technology Alliance project.