public final class Round extends Object
| Modifier and Type | Field and Description |
|---|---|
static RoundingMode |
CEILING |
static RoundingMode |
DOWN |
static RoundingMode |
FLOOR |
static RoundingMode |
HALF_DOWN |
static RoundingMode |
HALF_EVEN |
static RoundingMode |
HALF_UP |
static RoundingMode |
UNNECESSARY |
static RoundingMode |
UP |
| Modifier and Type | Method and Description |
|---|---|
static BigDecimal |
round(BigDecimal value)
Returns the closest integer to the argument, with ties rounding up.
|
static BigDecimal |
round(BigDecimal value,
int scale)
Round the given value to the specified number of decimal places.
|
static BigDecimal |
round(BigDecimal x,
int scale,
int rounding)
For backward compatibility
|
static BigDecimal |
round(BigDecimal x,
int scale,
RoundingMode rounding)
Round the given value to the specified number of decimal places.
|
static long |
round(double value)
Returns the closest
long to the argument, with ties rounding up. |
static Long |
round(Double value)
Like
round(double) but null-safe. |
static double |
round(double value,
int scale)
Round the given value to the specified number of decimal places.
|
static Double |
round(Double value,
int scale)
Like
round(double, int) but null-safe. |
static Double |
round(Double x,
int scale,
int rounding)
For backward compatibility
|
static double |
round(double x,
int scale,
RoundingMode rounding)
Round the given value to the specified number of decimal places.
|
static Double |
round(Double value,
int scale,
RoundingMode rounding)
Like
round(double, int, RoundingMode) but null-safe. |
static int |
round(float value)
Returns the closest
int to the argument, with ties rounding up. |
static Integer |
round(Float value)
Like
round(float) but null-safe. |
static float |
round(float value,
int scale)
Round the given value to the specified number of decimal places.
|
static Float |
round(Float value,
int scale)
Like
round(float, int) but null-safe. |
static Float |
round(Float x,
int scale,
int rounding)
For backward compatibility
|
static float |
round(float x,
int scale,
RoundingMode rounding)
Round the given value to the specified number of decimal places.
|
static Float |
round(Float value,
int scale,
RoundingMode rounding)
Like
round(float, int, RoundingMode) but null-safe. |
static Long |
roundStrict(Double value)
Like
round(double) but without a ulp amendment |
static Double |
roundStrict(Double value,
int scale)
Like
round(double) but without a ulp amendment |
public static final RoundingMode UP
public static final RoundingMode DOWN
public static final RoundingMode CEILING
public static final RoundingMode FLOOR
public static final RoundingMode HALF_UP
public static final RoundingMode HALF_DOWN
public static final RoundingMode HALF_EVEN
public static final RoundingMode UNNECESSARY
public static Long round(Double value)
round(double) but null-safe.public static long round(double value)
long to the argument, with ties rounding up. The value is rounded like using the
RoundingMode.HALF_UP method.
Special cases:
Long.MIN_VALUE,
the result is equal to the value of Long.MIN_VALUE.
Long.MAX_VALUE, the result is equal to the value of Long.MAX_VALUE.
value - a floating-point value to be rounded to a long.long value.public static Integer round(Float value)
round(float) but null-safe.public static int round(float value)
int to the argument, with ties rounding up. The value is rounded like using the
RoundingMode.HALF_UP method.
Special cases:
Integer.MIN_VALUE, the result is equal to the value of Integer.MIN_VALUE.
Integer.MAX_VALUE, the result is equal to the value of Integer.MAX_VALUE.
value - a floating-point value to be rounded to an integer.int value.public static BigDecimal round(BigDecimal value)
RoundingMode.HALF_UP method.public static Double round(Double value, int scale)
round(double, int) but null-safe.public static double round(double value,
int scale)
RoundingMode.HALF_UP method.value - the value to round.scale - the number of digits to the right of the decimal point.public static BigDecimal round(BigDecimal value, int scale)
RoundingMode.HALF_UP method.value - the value to round.scale - the number of digits to the right of the decimal point.public static Float round(Float value, int scale)
round(float, int) but null-safe.public static float round(float value,
int scale)
RoundingMode.HALF_UP method.value - the value to round.scale - the number of digits to the right of the decimal point.public static Double round(Double value, int scale, RoundingMode rounding)
round(double, int, RoundingMode) but null-safe.public static double round(double x,
int scale,
RoundingMode rounding)
RoundingMode.x - the value to round.scale - the number of digits to the right of the decimal point.rounding - the rounding method as defined in RoundingMode.public static Float round(Float value, int scale, RoundingMode rounding)
round(float, int, RoundingMode) but null-safe.public static float round(float x,
int scale,
RoundingMode rounding)
RoundingMode.x - the value to round.scale - the number of digits to the right of the decimal point.rounding - the rounding method as defined in RoundingMode.public static BigDecimal round(BigDecimal x, int scale, RoundingMode rounding)
RoundingMode.x - the value to round.scale - the number of digits to the right of the decimal point.rounding - the rounding method as defined in RoundingMode.public static BigDecimal round(BigDecimal x, int scale, int rounding)
public static Long roundStrict(Double value)
round(double) but without a ulp amendmentCopyright © 2004–2019 OpenL Tablets. All rights reserved.