Integer.round
Group: Rounding
Documentation
Round to a specified number of decimal places. For integers, rounding to 0 or more decimal places simply returns the argument. For negative decimal places, see below. By default, rounding uses "symmetric round-half-up", also known as "half-up." If rounding_mode=Rounding_Mode.Bankers, then it uses "round-half-even", also known as "banker's rounding".
Arguments
decimal_places: The number of decimal places to round to. Can be negative, which results in rounding to positive integer powers of 10. Must be between -15 and 15 (inclusive).rounding_mode: specifies how to break ties for the least significant digit.
Examples
Round an integer (returns the value unchanged).
3 . round == 3
Round to the nearest thousand.
2511 . round -3 == 3000
Round to the nearest hundred, using Banker's Rounding.
12250 . round -2 rounding_mode=Rounding_Mode.Bankers == 12200
Errors
If self is outside the range -99999999999999..99999999999999
(inclusive), an Illegal_Argument error is thrown. If decimal_places
is outside the range -15..15 (inclusive), an Illegal_Argument error is
thrown.
Remarks
Negative decimal place counts
Rounding to n digits can be thought of as "rounding to the nearest
multiple of 10^(-n)". For negative decimal counts, this results in
rounding to the nearest positive integer power of 10.