BigDecimal Rounding Mode Description:
Rounding mode is inside Java.math.RoundingMode:
Roundingmode.ceiling: Rounding mode rounded to the positive infinity direction. If the result is positive, the rounding behavior is similar to Roundingmode.up, and if the result is negative, the rounding behavior is similar to Roundingmode.down. Note that this rounding mode always does not reduce the calculated value
Enter number rounds a number to one digit using ceiling rounding mode
5.56
2.53
1.12
1.01
-1.0-1
-1.1-1
-1.6-1
-2.5-2
-5.5-5
Roundingmode.down: Rounding mode rounded in 0 direction. Do not add 1 (that is, truncated) to the number preceding the Discard section. Note that this rounding mode always does not increase the absolute value of calculated values
Entering a number rounds a number to one digit using the down rounding mode
5.55
2.52
1.11
-1.0-1
-1.6-1
-2.5-2
-5.5-5
Roundingmode.floor: Rounding mode rounded to a negative infinity direction. If the result is positive, the rounding behavior is similar to Roundingmode.down, and if the result is negative, the rounding behavior is similar to Roundingmode.up. Note that this rounding mode always does not increase the calculated value
Enter a number rounds the input number to one using floor rounding mode
5.55
2.32
1.61
1.01
-1.1-2
-2.5-3
-5.5-6
Roundingmode.half_down: Rounding mode rounded to the nearest number direction, rounded down if the distance to the two adjacent digits is equal. If part > 0.5 is discarded, the rounding behavior is the same as roundingmode.up; otherwise the rounding behavior is the same as Roundingmode.down
The input number is rounded to one using the Half_down input mode
5.55
2.52
1.62
1.01
-1.1-1
-1.6-2
-2.5-2
-5.5-5
Roundingmode.half_even: Rounding mode rounded to the nearest number direction, rounded to adjacent even if the distance from the two adjacent digits is equal. If the left part of the discard number is odd, the rounding behavior is the same as roundingmode.half_up, and if even, the rounding behavior is the same as Roundingmode.half_down. Note that this rounding mode minimizes cumulative errors on statistics when a series of calculations are repeated. This rounding mode is also known as the Banker rounding method, mainly used in the United States. This rounding pattern is similar to the rounding policy used by the float and double algorithms in Java
Enter a number use Half_even rounding mode to give the input a
5.56
2.52
1.62
1.11
-1.0-1
-1.6-2
-2.5-2
-5.5-6
ROUNDINGMODE.HALF_UP: Rounding mode rounded to the nearest number direction, rounded up if the distance to the two adjacent digits is equal. If part >= 0.5 is discarded, the rounding behavior is the same as roundingmode.up, otherwise the rounding behavior is the same as Roundingmode.down. Note that this rounding mode is usually rounded up in the school
The input number is rounded to one digit using HALF_UP rounding mode
5.56
2.53
1.62
1.01
-1.1-1
-1.6-2
-2.5-3
-5.5-6
Roundingmode.unnecessary: The rounding mode used to assert that the requested operation has a precise result, so no rounding is required. If this rounding mode is specified for operations that produce exact results, the ArithmeticException is thrown
Enter numbers using unnecessary mode
5.5 Throwing ArithmeticException
2.5 Throwing ArithmeticException
1.6 Throwing ArithmeticException
1.01
-1.0-1.0
-1.1 Throw ArithmeticException
-1.6 Throw ArithmeticException
-2.5 Throw ArithmeticException
-5.5 Throw ArithmeticException
Roundingmode.up: Rounding mode that is rounded away from the 0 direction. Always add 1 to the number preceding the part that is not 0 discarded. Note that this rounding mode always does not reduce the absolute value of calculated values
Enter number rounds the input number to one digit using up rounding mode
5.56
1.62
1.12
1.01
-1.1-2
-1.6-2
-2.5-3
-5.4-6
BigDecimal Precision Rounding Mode detailed