Round
Rounds a numeric value to a specified number of decimal places using standard mathematical rounding rules.
Syntax
Round(value, digits)
Parameters
- value (number): The numeric value to round
- digits (number, optional): Number of decimal places (defaults to 0, must be integer)
Returns
- number: The rounded value using banker’s rounding (round half to even)
Description
Uses .NET’s Math.Round implementation with banker’s rounding rules for consistent mathematical behavior. The digits parameter specifies the number of decimal places to preserve.
Examples
var result1 = Round(3.14159, 2) # Returns 3.14
var result2 = Round(2.5) # Returns 2 (banker's rounding)
var result3 = Round(3.5) # Returns 4 (banker's rounding)
var result4 = Round(123.456, 0) # Returns 123