RoundingMode
class RoundingMode
| kotlin.Any | ||
| ↳ | kotlin.Enum<java.math.RoundingMode> | |
| ↳ | java.math.RoundingMode | |
Specifies the rounding behavior for operations whose results cannot be represented exactly.
Summary
| Enum values | |
|---|---|
|
Rounding mode to round towards positive infinity. |
|
|
Rounding mode where the values are rounded towards zero. |
|
|
Rounding mode to round towards negative infinity. |
|
|
Rounding mode where values are rounded towards the nearest neighbor. |
|
|
Rounding mode where values are rounded towards the nearest neighbor. |
|
|
Rounding mode where values are rounded towards the nearest neighbor. |
|
|
Rounding mode where the rounding operations throws an ArithmeticException for the case that rounding is necessary, i. |
|
|
Rounding mode where positive values are rounded towards positive infinity and negative values towards negative infinity. |
|
| Public methods | |
|---|---|
| static RoundingMode! |
Converts rounding mode constants from class |
Enum values
CEILING
enum val CEILING : RoundingMode
Rounding mode to round towards positive infinity. For positive values this rounding mode behaves as UP, for negative values as DOWN.
Rule: x.round() >= x
DOWN
enum val DOWN : RoundingMode
Rounding mode where the values are rounded towards zero.
Rule: x.round().abs() <= x.abs()
FLOOR
enum val FLOOR : RoundingMode
Rounding mode to round towards negative infinity. For positive values this rounding mode behaves as DOWN, for negative values as UP.
Rule: x.round() <= x
HALF_DOWN
enum val HALF_DOWN : RoundingMode
Rounding mode where values are rounded towards the nearest neighbor. Ties are broken by rounding down.
HALF_EVEN
enum val HALF_EVEN : RoundingMode
Rounding mode where values are rounded towards the nearest neighbor. Ties are broken by rounding to the even neighbor.
HALF_UP
enum val HALF_UP : RoundingMode
Rounding mode where values are rounded towards the nearest neighbor. Ties are broken by rounding up.
UNNECESSARY
enum val UNNECESSARY : RoundingMode
Rounding mode where the rounding operations throws an ArithmeticException for the case that rounding is necessary, i.e. for the case that the value cannot be represented exactly.
UP
enum val UP : RoundingMode
Rounding mode where positive values are rounded towards positive infinity and negative values towards negative infinity.
Rule: x.round().abs() >= x.abs()
Public methods
valueOf
static fun valueOf(mode: Int): RoundingMode!
Converts rounding mode constants from class BigDecimal into RoundingMode values.
| Parameters | |
|---|---|
mode |
Int: rounding mode constant as defined in class BigDecimal |
| Return | |
|---|---|
RoundingMode! |
corresponding rounding mode object |