http://esffor.javaeye.com/blog/96157
ROUND_HALF_UP: When encountering. 5 of the case, the upper approximation, example: 1.5->;2
Round_half_down: When encountering. 5, approximate, example: 1.5->;1
BigDecimal a = new BigDecimal (1.5);
System.out.println ("down=" +a.setscale (0,bigdecimal.round_half_down) + "/tup=" +a.setscale (0,bigdecimal.round_half _UP));
Results: Down=1 up=2
See this example to understand!
Additional parameter description
Round_ceiling
If BigDecimal is positive, do round_up operation; if negative, do round_down operation.
Round_down
Increments the number before the decimal is not discarded (that is, truncated).
Round_floor
If the BigDecimal is positive, then it is round_up; if negative, it is round_down.
Round_half_down
If you discard part > 5, make round_up; otherwise, make round_down.
Round_half_even
If the left digit of the discard part is odd, then it is round_half_up; if it is an even number, it is round_half_down.
Round_half_up
If part >=.5 is discarded, it is round_up; otherwise, it is round_down.
Round_unnecessary
The pseudo-rounding mode actually indicates that the required operation must be accurate, so no rounding is required.
Round_up
always adds numbers before non- 0 Discard decimals (that is, truncate).