8240624: Note mapping of RoundingMode constants to equivalent IEEE 754-2019 attribute

Reviewed-by: bpb
This commit is contained in:
Joe Darcy 2020-03-05 15:07:20 -08:00
parent 4a32eda417
commit 001b8056c8

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -87,6 +87,13 @@ package java.math;
* ({@link BigDecimal#ROUND_UP}, {@link BigDecimal#ROUND_DOWN}, * ({@link BigDecimal#ROUND_UP}, {@link BigDecimal#ROUND_DOWN},
* etc. ). * etc. ).
* *
* @apiNote
* Five of the rounding modes declared in this class correspond to
* rounding direction attributes defined in the <cite>IEEE Standard
* for Floating-Point Arithmetic</cite>, IEEE 754-2019. Where present,
* this correspondence will be noted in the documentation of the
* particular constant.
*
* @see BigDecimal * @see BigDecimal
* @see MathContext * @see MathContext
* @author Josh Bloch * @author Josh Bloch
@ -130,6 +137,8 @@ public enum RoundingMode {
* Rounding mode to round towards zero. Never increments the digit * Rounding mode to round towards zero. Never increments the digit
* prior to a discarded fraction (i.e., truncates). Note that this * prior to a discarded fraction (i.e., truncates). Note that this
* rounding mode never increases the magnitude of the calculated value. * rounding mode never increases the magnitude of the calculated value.
* This mode corresponds to the IEEE 754-2019 rounding
* attribute roundTowardZero.
* *
*<p>Example: *<p>Example:
*<table class="striped"> *<table class="striped">
@ -159,6 +168,8 @@ public enum RoundingMode {
* result is positive, behaves as for {@code RoundingMode.UP}; * result is positive, behaves as for {@code RoundingMode.UP};
* if negative, behaves as for {@code RoundingMode.DOWN}. Note * if negative, behaves as for {@code RoundingMode.DOWN}. Note
* that this rounding mode never decreases the calculated value. * that this rounding mode never decreases the calculated value.
* This mode corresponds to the IEEE 754-2019 rounding
* attribute roundTowardPositive.
* *
*<p>Example: *<p>Example:
*<table class="striped"> *<table class="striped">
@ -188,6 +199,8 @@ public enum RoundingMode {
* result is positive, behave as for {@code RoundingMode.DOWN}; * result is positive, behave as for {@code RoundingMode.DOWN};
* if negative, behave as for {@code RoundingMode.UP}. Note that * if negative, behave as for {@code RoundingMode.UP}. Note that
* this rounding mode never increases the calculated value. * this rounding mode never increases the calculated value.
* This mode corresponds to the IEEE 754-2019 rounding
* attribute roundTowardNegative.
* *
*<p>Example: *<p>Example:
*<table class="striped"> *<table class="striped">
@ -219,6 +232,8 @@ public enum RoundingMode {
* fraction is &ge; 0.5; otherwise, behaves as for * fraction is &ge; 0.5; otherwise, behaves as for
* {@code RoundingMode.DOWN}. Note that this is the rounding * {@code RoundingMode.DOWN}. Note that this is the rounding
* mode commonly taught at school. * mode commonly taught at school.
* This mode corresponds to the IEEE 754-2019 rounding
* attribute roundTiesToAway.
* *
*<p>Example: *<p>Example:
*<table class="striped"> *<table class="striped">
@ -286,6 +301,8 @@ public enum RoundingMode {
* chiefly used in the USA. This rounding mode is analogous to * chiefly used in the USA. This rounding mode is analogous to
* the rounding policy used for {@code float} and {@code double} * the rounding policy used for {@code float} and {@code double}
* arithmetic in Java. * arithmetic in Java.
* This mode corresponds to the IEEE 754-2019 rounding
* attribute roundTiesToEven.
* *
*<p>Example: *<p>Example:
*<table class="striped"> *<table class="striped">