Java Reference
In-Depth Information
TABLE 8.5 ROUNDING OPTIONS IN JAVA AND COBOL
Mode
Description
COBOL Equivalent
ROUND_CEILING
Round toward positive infinity.
ROUND_DOWN
Round toward zero (and away from 10).
ROUND_FLOOR
Round toward negative infinity.
ROUND_HALF_DOWN
Round toward “nearest neighbor”
(i.e., toward 0 or 10). If both neighbors
are equidistant, round down.
ROUND_HALF_EVEN
Round toward the “nearest neighbor.”
If both are equidistant, round toward
the even neighbor.*
ROUND_HALF_UP
Round toward “nearest neighbor.”
ROUNDED
If both are equidistant, round up.
ROUND_UNNECESSARY
Asserts that the requested operation
has an exact result, and no rounding
is necessary.
ROUND_UP
Rounds away from zero (toward 10).
* This mode should, in theory, round up as often as it rounds down in case of equidistant neighbors, thereby reduc-
ing one source of rounding error.
Table 8.6 shows the most common math functions involving BigDecimal s.
 
Search WWH ::




Custom Search