double round(double val, int scale, int roundingMethod)
Rounds the given value to the specified number of decimal places. The value is rounded using the given method which is any method defined in java.math.BigDecimal. BigDecimal values are:
ROUND_UP = 0, Rounding mode to round away from zero.
ROUND_DOWN = 1, Rounding mode to round towards zero.
ROUND_CEILING = 2, Rounding mode to round towards positive infinity.
ROUND_FLOOR = 3, Rounding mode to round towards negative infinity.
ROUND_HALF_UP = 4, Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round up.
ROUND_HALF_DOWN = 5, Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round down.
ROUND_HALF_EVEN = 6, Rounding mode to round towards the "nearest neighbor" unless both neighbors are equidistant, in which case, round towards the even neighbor.
ROUND_UNNECESSARY = 7, Rounding mode to assert that the requested operation has an exact result, hence no rounding is necessary.
Input Parameters
val | Integer The value to round. |
scale | Integer The number of digits to the right of the decimal point. |
roundingMethod | Integer Rounding method as defined in BigDecimal. |
Return Value
Integer The rounded value. |