java.math
Enum RoundingMode
java.lang.Object
java.lang.Enum<RoundingMode>
java.math.RoundingMode
- All Implemented Interfaces:
- Serializable, Comparable<RoundingMode>
public enum RoundingMode
- extends Enum<RoundingMode>
An enum to specify rounding behaviour for numerical operations that may
discard precision.
Method Summary |
static RoundingMode |
valueOf(int rm)
Returns the RoundingMode object corresponding to the legacy rounding modes
in BigDecimal. |
static RoundingMode |
valueOf(String name)
Returns the enum constant of this type with the specified name. |
static RoundingMode[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared. |
UP
public static final RoundingMode UP
DOWN
public static final RoundingMode DOWN
CEILING
public static final RoundingMode CEILING
FLOOR
public static final RoundingMode FLOOR
HALF_UP
public static final RoundingMode HALF_UP
HALF_DOWN
public static final RoundingMode HALF_DOWN
HALF_EVEN
public static final RoundingMode HALF_EVEN
UNNECESSARY
public static final RoundingMode UNNECESSARY
values
public static RoundingMode[] values()
- Returns an array containing the constants of this enum type, in
the order they are declared. This method may be used to iterate
over the constants as follows:
for (RoundingMode c : RoundingMode.values())
System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in
the order they are declared
valueOf
public static RoundingMode valueOf(String name)
- Returns the enum constant of this type with the specified name.
The string must match exactly an identifier used to declare an
enum constant in this type. (Extraneous whitespace characters are
not permitted.)
- Parameters:
name
- the name of the enum constant to be returned.
- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant
with the specified name
NullPointerException
- if the argument is null
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