# RoundingMode.AwayFromZero

Updated on

RoundingMode.AwayFromZero (2) 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 away from zero.

## 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.AwayFromZero` makes sure that the rounding of the 4th decimals happens away from zero.

``````= Number.Round( 9.5555,  3,  2 )                         // Returns 9.556
= Number.Round( 9.5555,  3,  RoundingMode.AwayFromZero ) // Returns 9.556
= Number.Round( -9.5554, 3, RoundingMode.AwayFromZero ) // Returns -9.556``````

When the decimal to round is higher than half, it is also rounded up to the closest numbers that’s higher.

``= Number.Round( 9.6650, 2, RoundingMode.AwayFromZero ) // Returns 9.67``

Note that when Number having fewer decimals than instructed by the rounding, the entire value is returned unrounded.

``= Number.Round( 9.55, 3, RoundingMode.AwayFromZero ) // Returns 9.55``

You can find an example for all functions supporting the RoundingMode.Type below.

``````= Number.Round(  9.5, 0,    RoundingMode.AwayFromZero ) // Returns 10
= Number.Round( -9.5, 0,    RoundingMode.AwayFromZero ) // Returns -10

= Byte.From(     9.5, null, RoundingMode.AwayFromZero ) // Returns 10
= Byte.From(    -9.5, null, RoundingMode.AwayFromZero ) // Returns -10

= Int8.From(     9.5, null, RoundingMode.AwayFromZero ) // Returns 10
= Int8.From(    -9.5, null, RoundingMode.AwayFromZero ) // Returns -10

= Int16.From(   9.5, null, RoundingMode.AwayFromZero ) // Returns 10
= Int16.From(  -9.5, null, RoundingMode.AwayFromZero ) // Returns -10

= Int32.From(   9.5, null, RoundingMode.AwayFromZero ) // Returns 10
= Int32.From(  -9.5, null, RoundingMode.AwayFromZero ) // Returns -10

= Int64.From(   9.5, null, RoundingMode.AwayFromZero ) // Returns 10
= Int64.From(  -9.5, null, RoundingMode.AwayFromZero ) // Returns -10

// Currency From Function returns a maximum of 4 decimals
= Currency.From(  9.66005, null, RoundingMode.AwayFromZero )       // Returns  9.6601
= Currency.From( -9.66005,       null, RoundingMode.AwayFromZero ) // Returns -9.6601``````

Other related enumerations are:

## Applies to

Here’s a list of functions that work with RoundingMode.Type:

Contribute » | Contributors: Rick de Groot