Rounding Modes

The following rounding modes are used with ICU's Decimal Formatter.  Note that ICU's use of the terms "Down" and "Up" here are somewhat at odds with other definitions, but are equivalent to the same modes used in Java's JDK.

Comparison of Rounding Modes

This chart shows the values -2.0 through 2.0 in increments of 0.1, and shows the resulting ICU format when formatted with no decimal digits.
#CEILINGFLOORDOWNUPHALFEVENHALFDOWNHALFUP#
-2.0-2-2-2-2-2-2-2-2.0
-1.9-1-2-1-2-2-2-2-1.9
-1.8-1-2-1-2-2-2-2-1.8
-1.7-1-2-1-2-2-2-2-1.7
-1.6-1-2-1-2-2-2-2-1.6
-1.5-1-2-1-2-2-1-2-1.5
-1.4-1-2-1-2-1-1-1-1.4
-1.3-1-2-1-2-1-1-1-1.3
-1.2-1-2-1-2-1-1-1-1.2
-1.1-1-2-1-2-1-1-1-1.1
-1.0-1-1-1-1-1-1-1-1.0
-0.9-0-1-0-1-1-1-1-0.9
-0.8-0-1-0-1-1-1-1-0.8
-0.7-0-1-0-1-1-1-1-0.7
-0.6-0-1-0-1-1-1-1-0.6
-0.5-0-1-0-1-0-0-1-0.5
-0.4-0-1-0-1-0-0-0-0.4
-0.3-0-1-0-1-0-0-0-0.3
-0.2-0-1-0-1-0-0-0-0.2
-0.1-0-1-0-1-0-0-0-0.1
0.000000000.0
0.110010000.1
0.210010000.2
0.310010000.3
0.410010000.4
0.510010010.5
0.610011110.6
0.710011110.7
0.810011110.8
0.910011110.9
1.011111111.0
1.121121111.1
1.221121111.2
1.321121111.3
1.421121111.4
1.521122121.5
1.621122221.6
1.721122221.7
1.821122221.8
1.921122221.9
2.022222222.0
#CEILINGFLOORDOWNUPHALFEVENHALFDOWNHALFUP#

Half Even

This is ICU's default rounding mode. Values exactly on the 0.5 (half) mark (shown dotted in the chart) are rounded to the nearest even digit. This is often called Banker's Rounding because it is, on average, free of bias. It is the default mode specified for IEEE 754 floating point operations.
Also known as ties-to-even, round-to-nearest, RN or RNE.

Half Down

Values exactly on the 0.5 (half) mark are rounded down (next smaller absolute value, towards zero).

Half Up

Values exactly on the 0.5 (half) mark are rounded up (next larger absolute value, away from zero).

Down

All values are rounded towards the next smaller absolute value (rounded towards zero, or RZ). 
Also known as: truncation, because the insignificant decimal places are simply removed.

Up

All values are rounded towards the next greater absolute value (away from zero).

Ceiling

All values are rounded towards positive infinity (+∞). Also known as RI for Rounds to Infinity.

Floor

All values are rounded towards negative infinity (-∞). Also known as RMI for Rounds to Minus Infinity.

Unnecessary

The mode "Unnecessary" doesn't perform any rounding, but instead returns an error if the value cannot be represented exactly without rounding.

Other References/Comparison

Comments