Rounding modes

Rounding modes specify how numerical currency values are handled by Smile. Rounding a numerical value means replacing it by another value that is approximately equal but, has a shorter, simpler or more explicit representation. For example, the value $23.4476 is rounded up to two decimal places, resulting in the value $23.45.

Half Up (default)
Rounds towards the “nearest neighbour” unless both neighbours are equidistant, in which case, this mode rounds up to the next larger absolute value, away from zero. This rounding method behaves the same as the Up rounding method if the discarded fraction (decimal point) is >= 0.5. Otherwise this rounding method behaves the same as the Down rounding method.
Examples—
5.7 rounds up to 6
5.5 rounds up to 6
5.1 rounds down to 5
-1.1 rounds up to -1
-1.5 rounds up to -1
-1.7 rounds down to -2
Half Down
Rounds towards the “nearest neighbour” unless both neighbours are equidistant, in which case this mode rounds down to the next smaller absolute value, towards zero. This rounding mode behaves the same as the Up rounding mode if the discarded fraction (decimal point) is > 0.5. Otherwise it behaves the same as Down rounding mode.
Examples—
5.7 rounds up to 6
5.5 rounds down to 5
5.1 rounds down to 5
-1.1 rounds up to -1
-1.5 rounds down to -2
-1.7 rounds down to -2
Half Even
Rounds towards the “nearest neighbour” unless both neighbours are equidistant, in which case, this mode rounds towards the even neighbor. This rounding mode behaves the same as the Half Up rounding mode if the digit to the left of the discarded fraction (decimal point) is odd. It behaves the same as the Half Down rounding method if it is even.
Examples—
5.7 rounds up to 6
5.5 rounds up to 6
5.1 rounds down to 5
-1.1 rounds up to -1
-1.5 rounds down to -2
-1.7 rounds down to -2
Up
Rounds away from zero to the next greater absolute value. This rounding mode never decreases the magnitude of the calculated value.
Examples—
5.7 rounds up to 6
5.5 rounds up to 6
5.1 rounds up to 6
-1.1 rounds down to -2
-1.5 rounds down to -2
-1.7 rounds down to -2
Down
Rounds towards zero to the next smaller absolute value. This rounding mode never increases the magnitude of the calculated value.
Examples—
5.7 rounds down to 5
5.5 rounds down to 5
5.1 rounds down to 5
-1.1 rounds up to -1
-1.5 rounds up to -1
-1.7 rounds up to -1
Ceiling
Rounds towards positive infinity. If the result is positive, this mode behaves the same as the Up rounding mode. If the result is negative, it behaves the same as the Down rounding mode. This rounding mode never decreases the calculated value.
Examples—
5.7 rounds up to 6
5.5 rounds up to 6
5.1 rounds up to 6
-1.1 rounds up to -1
-1.5 rounds up to -1
-1.7 rounds up to -1
Floor
Rounds towards negative infinity. If the result is positive, this mode behaves the same as the Down rounding mode. If negative, this mode behaves the same as the Up rounding mode. This rounding mode never increases the calculated value.
Examples—
5.7 rounds down to 5
5.5 rounds down to 5
5.1 rounds down to 5
-1.1 rounds down to -2
-1.5 rounds down to -2
-1.7 rounds down to -2