Google is committed to advancing racial equity for Black communities. See how.
Added in API level 1

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!
valueOf(mode: Int)

Converts rounding mode constants from class BigDecimal into RoundingMode values.

Enum values

CEILING

Added in API level 1
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

Added in API level 1
enum val DOWN : RoundingMode

Rounding mode where the values are rounded towards zero.
Rule: x.round().abs() <= x.abs()

FLOOR

Added in API level 1
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

Added in API level 1
enum val HALF_DOWN : RoundingMode

Rounding mode where values are rounded towards the nearest neighbor. Ties are broken by rounding down.

HALF_EVEN

Added in API level 1
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

Added in API level 1
enum val HALF_UP : RoundingMode

Rounding mode where values are rounded towards the nearest neighbor. Ties are broken by rounding up.

UNNECESSARY

Added in API level 1
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

Added in API level 1
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

Added in API level 1
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