java.math

Class RoundingMode

public class RoundingMode extends Enum<RoundingMode>

An enum to specify rounding behaviour for numerical operations that may discard precision.
Field Summary
static RoundingModeCEILING
static RoundingModeDOWN
static RoundingModeFLOOR
static RoundingModeHALF_DOWN
static RoundingModeHALF_EVEN
static RoundingModeHALF_UP
static RoundingModeUNNECESSARY
static RoundingModeUP
static List<RoundingMode>VALUES
An immutable list containing the values comprising this enum class in the order they're declared.
Method Summary
List<RoundingMode>family()
Returns an immutable list containing the values comprising this enum class in the order they're declared.
static RoundingModevalueOf(String name)
Static factory to return the enum constant pertaining to the given string name.
static RoundingModevalueOf(int rm)
Returns the RoundingMode object corresponding to the legacy rounding modes in BigDecimal.

Field Detail

CEILING

public static final RoundingMode CEILING

DOWN

public static final RoundingMode DOWN

FLOOR

public static final RoundingMode FLOOR

HALF_DOWN

public static final RoundingMode HALF_DOWN

HALF_EVEN

public static final RoundingMode HALF_EVEN

HALF_UP

public static final RoundingMode HALF_UP

UNNECESSARY

public static final RoundingMode UNNECESSARY

UP

public static final RoundingMode UP

VALUES

public static final List<RoundingMode> VALUES
An immutable list containing the values comprising this enum class in the order they're declared. This field may be used to iterate over the constants as follows:
for(RoundingMode c : RoundingMode.VALUES)
    System.out.println(c);

Method Detail

family

public final List<RoundingMode> family()
Returns an immutable list containing the values comprising this enum class in the order they're declared. This instance method simply returns VALUES. Few programmers should have any need to use this method. It is provided for use by sophisticated enum-based data structures to prevent the need for reflective access to VALUES.

Returns: an immutable list containing the values comprising this enum class, in the order they're declared.

valueOf

public static final RoundingMode valueOf(String name)
Static factory to return the enum constant pertaining to the given string name. The string must match exactly an identifier used to declare an enum constant in this type.

Throws: IllegalArgumentException if this enum class has no constant with the specified name.

valueOf

public static RoundingMode valueOf(int rm)
Returns the RoundingMode object corresponding to the legacy rounding modes in BigDecimal.

Parameters: rm the legacy rounding mode

Returns: the corresponding RoundingMode