Version: v0.7.1 - Beta.  We welcome contributors & feedback.

Number.round

round($numDecimalDigits = 0) -> number

Description

Round to the specified number of digits after the decimal point.

Half fractions are rounded up. (e.g. 1.5 = 2, -1.5 = -2)

$num = 3.2
$num.round()  //= 3

$num = 3.5
$num.round()  //= 4

$num = 3.8
$num.round()  //= 4

$num = 1.2538
$num.round(2)  //= 1.25

$num = 1.025
$num.round(2)  //= 1.03

See Also