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:

number to round.

decimals
Number:

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

Returns

Integer: rounded number.
This page is generated from the comments in src/math/calculation.js . Please feel free to edit it and submit a pull request!

Related References