mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8265700: Regularize throws clauses in BigDecimal
Reviewed-by: bpb
This commit is contained in:
parent
71163213cb
commit
9e7c748db5
1 changed files with 8 additions and 31 deletions
|
@ -123,6 +123,11 @@ import java.util.Objects;
|
||||||
* 100×10<sup>1</sup>. In such cases, the new {@literal "1"} is
|
* 100×10<sup>1</sup>. In such cases, the new {@literal "1"} is
|
||||||
* the leading digit position of the returned result.
|
* the leading digit position of the returned result.
|
||||||
*
|
*
|
||||||
|
* <p>For methods and constructors with a {@code MathContext}
|
||||||
|
* parameter, if the result is inexact but the rounding mode is {@link
|
||||||
|
* RoundingMode#UNNECESSARY UNNECESSARY}, an {@code
|
||||||
|
* ArithmeticException} will be thrown.
|
||||||
|
*
|
||||||
* <p>Besides a logical exact result, each arithmetic operation has a
|
* <p>Besides a logical exact result, each arithmetic operation has a
|
||||||
* preferred scale for representing a result. The preferred
|
* preferred scale for representing a result. The preferred
|
||||||
* scale for each operation is listed in the table below.
|
* scale for each operation is listed in the table below.
|
||||||
|
@ -478,8 +483,6 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
|
||||||
* @param offset first character in the array to inspect.
|
* @param offset first character in the array to inspect.
|
||||||
* @param len number of characters to consider.
|
* @param len number of characters to consider.
|
||||||
* @param mc the context to use.
|
* @param mc the context to use.
|
||||||
* @throws ArithmeticException if the result is inexact but the
|
|
||||||
* rounding mode is {@code UNNECESSARY}.
|
|
||||||
* @throws NumberFormatException if {@code in} is not a valid
|
* @throws NumberFormatException if {@code in} is not a valid
|
||||||
* representation of a {@code BigDecimal} or the defined subarray
|
* representation of a {@code BigDecimal} or the defined subarray
|
||||||
* is not wholly within {@code in}.
|
* is not wholly within {@code in}.
|
||||||
|
@ -780,8 +783,6 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
|
||||||
*
|
*
|
||||||
* @param in {@code char} array that is the source of characters.
|
* @param in {@code char} array that is the source of characters.
|
||||||
* @param mc the context to use.
|
* @param mc the context to use.
|
||||||
* @throws ArithmeticException if the result is inexact but the
|
|
||||||
* rounding mode is {@code UNNECESSARY}.
|
|
||||||
* @throws NumberFormatException if {@code in} is not a valid
|
* @throws NumberFormatException if {@code in} is not a valid
|
||||||
* representation of a {@code BigDecimal}.
|
* representation of a {@code BigDecimal}.
|
||||||
* @since 1.5
|
* @since 1.5
|
||||||
|
@ -903,8 +904,6 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
|
||||||
*
|
*
|
||||||
* @param val string representation of a {@code BigDecimal}.
|
* @param val string representation of a {@code BigDecimal}.
|
||||||
* @param mc the context to use.
|
* @param mc the context to use.
|
||||||
* @throws ArithmeticException if the result is inexact but the
|
|
||||||
* rounding mode is {@code UNNECESSARY}.
|
|
||||||
* @throws NumberFormatException if {@code val} is not a valid
|
* @throws NumberFormatException if {@code val} is not a valid
|
||||||
* representation of a BigDecimal.
|
* representation of a BigDecimal.
|
||||||
* @since 1.5
|
* @since 1.5
|
||||||
|
@ -974,8 +973,6 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
|
||||||
* @param val {@code double} value to be converted to
|
* @param val {@code double} value to be converted to
|
||||||
* {@code BigDecimal}.
|
* {@code BigDecimal}.
|
||||||
* @param mc the context to use.
|
* @param mc the context to use.
|
||||||
* @throws ArithmeticException if the result is inexact but the
|
|
||||||
* RoundingMode is UNNECESSARY.
|
|
||||||
* @throws NumberFormatException if {@code val} is infinite or NaN.
|
* @throws NumberFormatException if {@code val} is infinite or NaN.
|
||||||
* @since 1.5
|
* @since 1.5
|
||||||
*/
|
*/
|
||||||
|
@ -1082,8 +1079,6 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
|
||||||
* @param val {@code BigInteger} value to be converted to
|
* @param val {@code BigInteger} value to be converted to
|
||||||
* {@code BigDecimal}.
|
* {@code BigDecimal}.
|
||||||
* @param mc the context to use.
|
* @param mc the context to use.
|
||||||
* @throws ArithmeticException if the result is inexact but the
|
|
||||||
* rounding mode is {@code UNNECESSARY}.
|
|
||||||
* @since 1.5
|
* @since 1.5
|
||||||
*/
|
*/
|
||||||
public BigDecimal(BigInteger val, MathContext mc) {
|
public BigDecimal(BigInteger val, MathContext mc) {
|
||||||
|
@ -1117,8 +1112,6 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
|
||||||
* @param unscaledVal unscaled value of the {@code BigDecimal}.
|
* @param unscaledVal unscaled value of the {@code BigDecimal}.
|
||||||
* @param scale scale of the {@code BigDecimal}.
|
* @param scale scale of the {@code BigDecimal}.
|
||||||
* @param mc the context to use.
|
* @param mc the context to use.
|
||||||
* @throws ArithmeticException if the result is inexact but the
|
|
||||||
* rounding mode is {@code UNNECESSARY}.
|
|
||||||
* @since 1.5
|
* @since 1.5
|
||||||
*/
|
*/
|
||||||
public BigDecimal(BigInteger unscaledVal, int scale, MathContext mc) {
|
public BigDecimal(BigInteger unscaledVal, int scale, MathContext mc) {
|
||||||
|
@ -1180,8 +1173,6 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
|
||||||
*
|
*
|
||||||
* @param val {@code int} value to be converted to {@code BigDecimal}.
|
* @param val {@code int} value to be converted to {@code BigDecimal}.
|
||||||
* @param mc the context to use.
|
* @param mc the context to use.
|
||||||
* @throws ArithmeticException if the result is inexact but the
|
|
||||||
* rounding mode is {@code UNNECESSARY}.
|
|
||||||
* @since 1.5
|
* @since 1.5
|
||||||
*/
|
*/
|
||||||
public BigDecimal(int val, MathContext mc) {
|
public BigDecimal(int val, MathContext mc) {
|
||||||
|
@ -1225,8 +1216,6 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
|
||||||
*
|
*
|
||||||
* @param val {@code long} value to be converted to {@code BigDecimal}.
|
* @param val {@code long} value to be converted to {@code BigDecimal}.
|
||||||
* @param mc the context to use.
|
* @param mc the context to use.
|
||||||
* @throws ArithmeticException if the result is inexact but the
|
|
||||||
* rounding mode is {@code UNNECESSARY}.
|
|
||||||
* @since 1.5
|
* @since 1.5
|
||||||
*/
|
*/
|
||||||
public BigDecimal(long val, MathContext mc) {
|
public BigDecimal(long val, MathContext mc) {
|
||||||
|
@ -1400,8 +1389,6 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
|
||||||
* @param augend value to be added to this {@code BigDecimal}.
|
* @param augend value to be added to this {@code BigDecimal}.
|
||||||
* @param mc the context to use.
|
* @param mc the context to use.
|
||||||
* @return {@code this + augend}, rounded as necessary.
|
* @return {@code this + augend}, rounded as necessary.
|
||||||
* @throws ArithmeticException if the result is inexact but the
|
|
||||||
* rounding mode is {@code UNNECESSARY}.
|
|
||||||
* @since 1.5
|
* @since 1.5
|
||||||
*/
|
*/
|
||||||
public BigDecimal add(BigDecimal augend, MathContext mc) {
|
public BigDecimal add(BigDecimal augend, MathContext mc) {
|
||||||
|
@ -1550,8 +1537,6 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
|
||||||
* @param subtrahend value to be subtracted from this {@code BigDecimal}.
|
* @param subtrahend value to be subtracted from this {@code BigDecimal}.
|
||||||
* @param mc the context to use.
|
* @param mc the context to use.
|
||||||
* @return {@code this - subtrahend}, rounded as necessary.
|
* @return {@code this - subtrahend}, rounded as necessary.
|
||||||
* @throws ArithmeticException if the result is inexact but the
|
|
||||||
* rounding mode is {@code UNNECESSARY}.
|
|
||||||
* @since 1.5
|
* @since 1.5
|
||||||
*/
|
*/
|
||||||
public BigDecimal subtract(BigDecimal subtrahend, MathContext mc) {
|
public BigDecimal subtract(BigDecimal subtrahend, MathContext mc) {
|
||||||
|
@ -1593,8 +1578,6 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
|
||||||
* @param multiplicand value to be multiplied by this {@code BigDecimal}.
|
* @param multiplicand value to be multiplied by this {@code BigDecimal}.
|
||||||
* @param mc the context to use.
|
* @param mc the context to use.
|
||||||
* @return {@code this * multiplicand}, rounded as necessary.
|
* @return {@code this * multiplicand}, rounded as necessary.
|
||||||
* @throws ArithmeticException if the result is inexact but the
|
|
||||||
* rounding mode is {@code UNNECESSARY}.
|
|
||||||
* @since 1.5
|
* @since 1.5
|
||||||
*/
|
*/
|
||||||
public BigDecimal multiply(BigDecimal multiplicand, MathContext mc) {
|
public BigDecimal multiply(BigDecimal multiplicand, MathContext mc) {
|
||||||
|
@ -2597,8 +2580,6 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
|
||||||
*
|
*
|
||||||
* @param mc the context to use.
|
* @param mc the context to use.
|
||||||
* @return {@code abs(this)}, rounded as necessary.
|
* @return {@code abs(this)}, rounded as necessary.
|
||||||
* @throws ArithmeticException if the result is inexact but the
|
|
||||||
* rounding mode is {@code UNNECESSARY}.
|
|
||||||
* @since 1.5
|
* @since 1.5
|
||||||
*/
|
*/
|
||||||
public BigDecimal abs(MathContext mc) {
|
public BigDecimal abs(MathContext mc) {
|
||||||
|
@ -2625,8 +2606,6 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
|
||||||
*
|
*
|
||||||
* @param mc the context to use.
|
* @param mc the context to use.
|
||||||
* @return {@code -this}, rounded as necessary.
|
* @return {@code -this}, rounded as necessary.
|
||||||
* @throws ArithmeticException if the result is inexact but the
|
|
||||||
* rounding mode is {@code UNNECESSARY}.
|
|
||||||
* @since 1.5
|
* @since 1.5
|
||||||
*/
|
*/
|
||||||
public BigDecimal negate(MathContext mc) {
|
public BigDecimal negate(MathContext mc) {
|
||||||
|
@ -2659,8 +2638,6 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
|
||||||
* @param mc the context to use.
|
* @param mc the context to use.
|
||||||
* @return {@code this}, rounded as necessary. A zero result will
|
* @return {@code this}, rounded as necessary. A zero result will
|
||||||
* have a scale of 0.
|
* have a scale of 0.
|
||||||
* @throws ArithmeticException if the result is inexact but the
|
|
||||||
* rounding mode is {@code UNNECESSARY}.
|
|
||||||
* @see #round(MathContext)
|
* @see #round(MathContext)
|
||||||
* @since 1.5
|
* @since 1.5
|
||||||
*/
|
*/
|
||||||
|
@ -2842,9 +2819,6 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
|
||||||
* @param mc the context to use.
|
* @param mc the context to use.
|
||||||
* @return a {@code BigDecimal} rounded according to the
|
* @return a {@code BigDecimal} rounded according to the
|
||||||
* {@code MathContext} settings.
|
* {@code MathContext} settings.
|
||||||
* @throws ArithmeticException if the rounding mode is
|
|
||||||
* {@code UNNECESSARY} and the
|
|
||||||
* {@code BigDecimal} operation would require rounding.
|
|
||||||
* @see #plus(MathContext)
|
* @see #plus(MathContext)
|
||||||
* @since 1.5
|
* @since 1.5
|
||||||
*/
|
*/
|
||||||
|
@ -3093,6 +3067,7 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
|
||||||
*
|
*
|
||||||
* @return a numerically equal {@code BigDecimal} with any
|
* @return a numerically equal {@code BigDecimal} with any
|
||||||
* trailing zeros removed.
|
* trailing zeros removed.
|
||||||
|
* @throws ArithmeticException if scale overflows.
|
||||||
* @since 1.5
|
* @since 1.5
|
||||||
*/
|
*/
|
||||||
public BigDecimal stripTrailingZeros() {
|
public BigDecimal stripTrailingZeros() {
|
||||||
|
@ -4924,6 +4899,7 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
|
||||||
*
|
*
|
||||||
* @return new {@code BigDecimal} with a scale possibly reduced
|
* @return new {@code BigDecimal} with a scale possibly reduced
|
||||||
* to be closed to the preferred scale.
|
* to be closed to the preferred scale.
|
||||||
|
* @throws ArithmeticException if scale overflows.
|
||||||
*/
|
*/
|
||||||
private static BigDecimal createAndStripZerosToMatchScale(BigInteger intVal, int scale, long preferredScale) {
|
private static BigDecimal createAndStripZerosToMatchScale(BigInteger intVal, int scale, long preferredScale) {
|
||||||
BigInteger qr[]; // quotient-remainder pair
|
BigInteger qr[]; // quotient-remainder pair
|
||||||
|
@ -4948,6 +4924,7 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
|
||||||
*
|
*
|
||||||
* @return new {@code BigDecimal} with a scale possibly reduced
|
* @return new {@code BigDecimal} with a scale possibly reduced
|
||||||
* to be closed to the preferred scale.
|
* to be closed to the preferred scale.
|
||||||
|
* @throws ArithmeticException if scale overflows.
|
||||||
*/
|
*/
|
||||||
private static BigDecimal createAndStripZerosToMatchScale(long compactVal, int scale, long preferredScale) {
|
private static BigDecimal createAndStripZerosToMatchScale(long compactVal, int scale, long preferredScale) {
|
||||||
while (Math.abs(compactVal) >= 10L && scale > preferredScale) {
|
while (Math.abs(compactVal) >= 10L && scale > preferredScale) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue