Most visited

Recently visited

Added in API level 1

RoundingMode

public final enum RoundingMode
extends Enum<RoundingMode>

java.lang.Object
   ↳ java.lang.Enum<java.math.RoundingMode>
     ↳ java.math.RoundingMode


Specifies the rounding behavior for operations whose results cannot be represented exactly.

Summary

Enum values

RoundingMode  CEILING

Rounding mode to round towards positive infinity. 

RoundingMode  DOWN

Rounding mode where the values are rounded towards zero. 

RoundingMode  FLOOR

Rounding mode to round towards negative infinity. 

RoundingMode  HALF_DOWN

Rounding mode where values are rounded towards the nearest neighbor. 

RoundingMode  HALF_EVEN

Rounding mode where values are rounded towards the nearest neighbor. 

RoundingMode  HALF_UP

Rounding mode where values are rounded towards the nearest neighbor. 

RoundingMode  UNNECESSARY

Rounding mode where the rounding operations throws an ArithmeticException for the case that rounding is necessary, i.e. 

RoundingMode  UP

Rounding mode where positive values are rounded towards positive infinity and negative values towards negative infinity. 

Public methods

static RoundingMode valueOf(String name)
static RoundingMode valueOf(int mode)

Converts rounding mode constants from class BigDecimal into RoundingMode values.

static final RoundingMode[] values()

Inherited methods

From class java.lang.Enum
From class java.lang.Object
From interface java.lang.Comparable

Enum values

CEILING

Added in API level 1
RoundingMode CEILING

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
RoundingMode DOWN

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

FLOOR

Added in API level 1
RoundingMode FLOOR

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
RoundingMode HALF_DOWN

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

HALF_EVEN

Added in API level 1
RoundingMode HALF_EVEN

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
RoundingMode HALF_UP

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

UNNECESSARY

Added in API level 1
RoundingMode UNNECESSARY

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
RoundingMode UP

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
RoundingMode valueOf (String name)

Parameters
name String
Returns
RoundingMode

valueOf

Added in API level 1
RoundingMode valueOf (int mode)

Converts rounding mode constants from class BigDecimal into RoundingMode values.

Parameters
mode int: rounding mode constant as defined in class BigDecimal
Returns
RoundingMode corresponding rounding mode object

values

Added in API level 1
RoundingMode[] values ()

Returns
RoundingMode[]

Hooray!