Reference round()

round()

Calculates the integer closest to a number.

For example, round(133.8) returns the value 134.

The second parameter, decimals, is optional. It sets the number of decimal places to use when rounding. For example, round(12.34, 1) returns 12.3. decimals is 0 by default.

Examples

Syntax

round(n, [decimals])

Parameters

n

number to round.

decimals

number of decimal places to round to, default is 0.

Notice any errors or typos? Please let us know. Please feel free to edit src/math/calculation.js and open a pull request!

Related References