Package dev.nm.number
Enum DoubleUtils.RoundingScheme
- java.lang.Object
-
- java.lang.Enum<DoubleUtils.RoundingScheme>
-
- dev.nm.number.DoubleUtils.RoundingScheme
-
- All Implemented Interfaces:
Serializable
,Comparable<DoubleUtils.RoundingScheme>
- Enclosing class:
- DoubleUtils
public static enum DoubleUtils.RoundingScheme extends Enum<DoubleUtils.RoundingScheme>
the available schemes to round a number
-
-
Enum Constant Summary
Enum Constants Enum Constant Description DEFAULT
This rounding scheme is the same as inMath.round(float)
.DOWN
Always round down.UP
Always round up.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static DoubleUtils.RoundingScheme
valueOf(String name)
Returns the enum constant of this type with the specified name.static DoubleUtils.RoundingScheme[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
DEFAULT
public static final DoubleUtils.RoundingScheme DEFAULT
This rounding scheme is the same as inMath.round(float)
. That is, returning the closest long to the input. The input is rounded to an integer by adding 1/2, taking the floor, and casting it tolong
.
-
UP
public static final DoubleUtils.RoundingScheme UP
Always round up. This is done by taking the ceiling of the input after subtracting a very tiny number.
-
DOWN
public static final DoubleUtils.RoundingScheme DOWN
Always round down. This is done by taking the floor of the input after adding a very tiny number.
-
-
Method Detail
-
values
public static DoubleUtils.RoundingScheme[] 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 (DoubleUtils.RoundingScheme c : DoubleUtils.RoundingScheme.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static DoubleUtils.RoundingScheme 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 nameNullPointerException
- if the argument is null
-
-