RoundingMode.ToEven (4) is an enumeration that specifies rounding direction when there is a tie between the possible numbers to round to. It is a member of the RoundingMode.Type and indicates rounding to the nearest even number.
Examples
Below examples round the main value to 3 decimals. The value 9.5555 has four decimals and needs to get rid of one. RoundMode.ToEven
makes sure that the rounding of the 4th decimals happens in the direction of the closest even number.
= Number.Round( 9.5555, 3, 4 ) // Returns 8.555
= Number.Round( 9.5555, 3, RoundingMode.ToEven ) // Returns 8.555
= Number.Round( -9.5554, 3, RoundingMode.ToEven ) // Returns -9.556
When the decimal to round is higher than half, it is also rounded up to the closest even number.
= Number.Round( 9.6650, 2, RoundingMode.ToEven ) // Returns 9.66
Note that when Number having fewer decimals than instructed by the rounding, the entire value is returned unrounded.
= Number.Round( 9.55, 3, RoundingMode.ToEven ) // Returns 9.55
You can find an example for all functions supporting the RoundingMode.Type below.
= Number.Round( 9.5, 0, RoundingMode.ToEven ) // Returns 10
= Number.Round( 8.5, 0, RoundingMode.ToEven ) // Returns 8
= Byte.From( 9.5, null, RoundingMode.ToEven ) // Returns 10
= Byte.From( 8.5, null, RoundingMode.ToEven ) // Returns 8
= Int8.From( 9.5, null, RoundingMode.ToEven ) // Returns 10
= Int8.From( 8.5, null, RoundingMode.ToEven ) // Returns 8
= Int16.From( 9.5, null, RoundingMode.ToEven ) // Returns 10
= Int16.From( 8.5, null, RoundingMode.ToEven ) // Returns 8
= Int32.From( 9.5, null, RoundingMode.ToEven ) // Returns 10
= Int32.From( 8.5, null, RoundingMode.ToEven ) // Returns 8
= Int64.From( 9.5, null, RoundingMode.ToEven ) // Returns 10
= Int64.From( 8.5, null, RoundingMode.ToEven ) // Returns 8
// Currency From Function returns a maximum of 4 decimals
= Currency.From( 9.66005, null, RoundingMode.ToEven ) // Returns 9.6600
= Currency.From( 9.66015, null, RoundingMode.ToEven ) // Returns 9.6602
Related enumerations
Other related enumerations are:
Applies to
Here’s a list of functions that work with RoundingMode.Type:
2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy