public enum UncheckedRounding extends Enum<UncheckedRounding> implements TruncationPolicy
TruncationPolicy for OverflowMode.UNCHECKED. The constants
are equivalent to the constants defined by RoundingMode; the policy's getOverflowMode() method
always returns UNCHECKED overflow mode.| Enum Constant and Description |
|---|
CEILING
Unchecked truncation policy with rounding mode to round towards positive infinity.
|
DOWN
Unchecked truncation policy with rounding mode to round towards zero.
|
FLOOR
Unchecked truncation policy with rounding mode to round towards negative infinity.
|
HALF_DOWN
Unchecked truncation policy with rounding mode to round towards "nearest neighbor" unless both
neighbors are equidistant, in which case round down.
|
HALF_EVEN
Unchecked truncation policy with rounding mode to round towards the "nearest neighbor" unless both
neighbors are equidistant, in which case, round towards the even neighbor.
|
HALF_UP
Unchecked truncation policy with rounding mode to round towards "nearest neighbor" unless both
neighbors are equidistant, in which case round up.
|
UNNECESSARY
Unchecked truncation policy with rounding mode to assert that the requested operation has an exact result, hence
no rounding is necessary.
|
UP
Unchecked truncation policy with rounding mode to round away from zero.
|
| Modifier and Type | Field and Description |
|---|---|
static Set<UncheckedRounding> |
VALUES
Immutable set with all values of this enum.
|
DEFAULT| Modifier and Type | Method and Description |
|---|---|
OverflowMode |
getOverflowMode()
Returns
OverflowMode.UNCHECKED. |
abstract CheckedRounding |
toCheckedRounding()
Returns the policy with the same
rounding mode as this unchecked rounding policy but
for CHECKED overflow mode. |
String |
toString()
Returns "UNCHECKED/(name)" where
(name) stands for the Enum.name() of this constant. |
static UncheckedRounding |
valueOf(RoundingMode roundingMode)
Returns the checked rounding constant for the given rounding mode.
|
static UncheckedRounding |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static UncheckedRounding[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, valueOfgetRoundingModepublic static final UncheckedRounding UP
RoundingMode.UPpublic static final UncheckedRounding DOWN
RoundingMode.DOWNpublic static final UncheckedRounding CEILING
RoundingMode.UP; if negative, behaves as for RoundingMode.DOWN. Note that this
rounding mode never decreases the calculated value.RoundingMode.CEILINGpublic static final UncheckedRounding FLOOR
RoundingMode.DOWN; if negative, behave as for RoundingMode.UP. Note that this
rounding mode never increases the calculated value.RoundingMode.FLOORpublic static final UncheckedRounding HALF_UP
RoundingMode.UP if the discarded
fraction is ≥ 0.5; otherwise, behaves as for RoundingMode.DOWN. Note that this is the rounding mode
commonly taught at school.RoundingMode.HALF_UPpublic static final UncheckedRounding HALF_DOWN
RoundingMode.UP if the discarded
fraction is > 0.5; otherwise, behaves as for RoundingMode.DOWN.RoundingMode.HALF_DOWNpublic static final UncheckedRounding HALF_EVEN
RoundingMode.HALF_UP if the digit to the left of the discarded fraction is odd; behaves as for
RoundingMode.HALF_DOWN if it's even. Note that this is the rounding mode that statistically minimizes
cumulative error when applied repeatedly over a sequence of calculations. It is sometimes known as
"Banker's rounding," and is chiefly used in the USA. This rounding mode is analogous to the rounding
policy used for float and double arithmetic in Java.RoundingMode.HALF_EVENpublic static final UncheckedRounding UNNECESSARY
ArithmeticException is thrown.RoundingMode.UNNECESSARYpublic static final Set<UncheckedRounding> VALUES
values().public static UncheckedRounding[] values()
for (UncheckedRounding c : UncheckedRounding.values()) System.out.println(c);
public static UncheckedRounding valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullpublic final OverflowMode getOverflowMode()
OverflowMode.UNCHECKED.getOverflowMode in interface TruncationPolicypublic abstract CheckedRounding toCheckedRounding()
rounding mode as this unchecked rounding policy but
for CHECKED overflow mode.CheckedRounding counterpart to this policy.public final String toString()
(name) stands for the Enum.name() of this constant.toString in class Enum<UncheckedRounding>public static final UncheckedRounding valueOf(RoundingMode roundingMode)
roundingMode - the rounding mode