< prev index next >

src/java.base/share/classes/java/math/RoundingMode.java

Print this page

        

*** 85,94 **** --- 85,100 ---- * <p>This {@code enum} is intended to replace the integer-based * enumeration of rounding mode constants in {@link BigDecimal} * ({@link BigDecimal#ROUND_UP}, {@link BigDecimal#ROUND_DOWN}, * etc. ). * + * @apiNote + * Five of the rounding modes defined in this class correspond to + * rounding direction attributes defined in IEEE 754-2019. Where + * present, this correspondence will be noted in the documentation of + * the particular constant. + * * @see BigDecimal * @see MathContext * @author Josh Bloch * @author Mike Cowlishaw * @author Joseph D. Darcy
*** 128,137 **** --- 134,145 ---- /** * Rounding mode to round towards zero. Never increments the digit * prior to a discarded fraction (i.e., truncates). Note that this * rounding mode never increases the magnitude of the calculated value. + * This mode corresponds to the IEEE 754-2019 rounding + * attribute roundTowardZero. * *<p>Example: *<table class="striped"> * <caption>Rounding mode DOWN Examples</caption> *<thead>
*** 157,166 **** --- 165,176 ---- /** * Rounding mode to round towards positive infinity. If the * result is positive, behaves as for {@code RoundingMode.UP}; * if negative, behaves as for {@code RoundingMode.DOWN}. Note * that this rounding mode never decreases the calculated value. + * This mode corresponds to the IEEE 754-2019 rounding + * attribute roundTowardPositive. * *<p>Example: *<table class="striped"> * <caption>Rounding mode CEILING Examples</caption> *<thead>
*** 186,195 **** --- 196,207 ---- /** * Rounding mode to round towards negative infinity. If the * result is positive, behave as for {@code RoundingMode.DOWN}; * if negative, behave as for {@code RoundingMode.UP}. Note that * this rounding mode never increases the calculated value. + * This mode corresponds to the IEEE 754-2019 rounding + * attribute roundTowardNegative. * *<p>Example: *<table class="striped"> * <caption>Rounding mode FLOOR Examples</caption> *<thead>
*** 217,226 **** --- 229,240 ---- * unless both neighbors are equidistant, in which case round up. * Behaves as for {@code RoundingMode.UP} if the discarded * fraction is &ge; 0.5; otherwise, behaves as for * {@code RoundingMode.DOWN}. Note that this is the rounding * mode commonly taught at school. + * This mode corresponds to the IEEE 754-2019 rounding + * attribute roundTiesToAway. * *<p>Example: *<table class="striped"> * <caption>Rounding mode HALF_UP Examples</caption> *<thead>
*** 284,293 **** --- 298,309 ---- * error when applied repeatedly over a sequence of calculations. * It is sometimes known as {@literal "Banker's rounding,"} and is * chiefly used in the USA. This rounding mode is analogous to * the rounding policy used for {@code float} and {@code double} * arithmetic in Java. + * This mode corresponds to the IEEE 754-2019 rounding + * attribute roundTiesToEven. * *<p>Example: *<table class="striped"> * <caption>Rounding mode HALF_EVEN Examples</caption> *<thead>
< prev index next >