Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8265700: Regularize throws clauses in BigDecimal #3608

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter
Filter file types
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.

Always

Just for now

@@ -123,6 +123,11 @@
* 100&times;10<sup>1</sup>. In such cases, the new {@literal "1"} is
* 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
* preferred scale for representing a result. The preferred
* scale for each operation is listed in the table below.
@@ -478,8 +483,6 @@ public BigDecimal(char[] in, int offset, int len) {
* @param offset first character in the array to inspect.
* @param len number of characters to consider.
* @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
* representation of a {@code BigDecimal} or the defined subarray
* is not wholly within {@code in}.
@@ -780,8 +783,6 @@ public BigDecimal(char[] in) {
*
* @param in {@code char} array that is the source of characters.
* @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
* representation of a {@code BigDecimal}.
* @since 1.5
@@ -903,8 +904,6 @@ public BigDecimal(String val) {
*
* @param val string representation of a {@code BigDecimal}.
* @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
* representation of a BigDecimal.
* @since 1.5
@@ -974,8 +973,6 @@ public BigDecimal(double val) {
* @param val {@code double} value to be converted to
* {@code BigDecimal}.
* @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.
* @since 1.5
*/
@@ -1082,8 +1079,6 @@ public BigDecimal(BigInteger val) {
* @param val {@code BigInteger} value to be converted to
* {@code BigDecimal}.
* @param mc the context to use.
* @throws ArithmeticException if the result is inexact but the
* rounding mode is {@code UNNECESSARY}.
* @since 1.5
*/
public BigDecimal(BigInteger val, MathContext mc) {
@@ -1117,8 +1112,6 @@ public BigDecimal(BigInteger unscaledVal, int scale) {
* @param unscaledVal unscaled value of the {@code BigDecimal}.
* @param scale scale of the {@code BigDecimal}.
* @param mc the context to use.
* @throws ArithmeticException if the result is inexact but the
* rounding mode is {@code UNNECESSARY}.
* @since 1.5
*/
public BigDecimal(BigInteger unscaledVal, int scale, MathContext mc) {
@@ -1180,8 +1173,6 @@ public BigDecimal(int val) {
*
* @param val {@code int} value to be converted to {@code BigDecimal}.
* @param mc the context to use.
* @throws ArithmeticException if the result is inexact but the
* rounding mode is {@code UNNECESSARY}.
* @since 1.5
*/
public BigDecimal(int val, MathContext mc) {
@@ -1225,8 +1216,6 @@ public BigDecimal(long val) {
*
* @param val {@code long} value to be converted to {@code BigDecimal}.
* @param mc the context to use.
* @throws ArithmeticException if the result is inexact but the
* rounding mode is {@code UNNECESSARY}.
* @since 1.5
*/
public BigDecimal(long val, MathContext mc) {
@@ -1400,8 +1389,6 @@ public BigDecimal add(BigDecimal augend) {
* @param augend value to be added to this {@code BigDecimal}.
* @param mc the context to use.
* @return {@code this + augend}, rounded as necessary.
* @throws ArithmeticException if the result is inexact but the
* rounding mode is {@code UNNECESSARY}.
* @since 1.5
*/
public BigDecimal add(BigDecimal augend, MathContext mc) {
@@ -1550,8 +1537,6 @@ public BigDecimal subtract(BigDecimal subtrahend) {
* @param subtrahend value to be subtracted from this {@code BigDecimal}.
* @param mc the context to use.
* @return {@code this - subtrahend}, rounded as necessary.
* @throws ArithmeticException if the result is inexact but the
* rounding mode is {@code UNNECESSARY}.
* @since 1.5
*/
public BigDecimal subtract(BigDecimal subtrahend, MathContext mc) {
@@ -1593,8 +1578,6 @@ public BigDecimal multiply(BigDecimal multiplicand) {
* @param multiplicand value to be multiplied by this {@code BigDecimal}.
* @param mc the context to use.
* @return {@code this * multiplicand}, rounded as necessary.
* @throws ArithmeticException if the result is inexact but the
* rounding mode is {@code UNNECESSARY}.
* @since 1.5
*/
public BigDecimal multiply(BigDecimal multiplicand, MathContext mc) {
@@ -2597,8 +2580,6 @@ public BigDecimal abs() {
*
* @param mc the context to use.
* @return {@code abs(this)}, rounded as necessary.
* @throws ArithmeticException if the result is inexact but the
* rounding mode is {@code UNNECESSARY}.
* @since 1.5
*/
public BigDecimal abs(MathContext mc) {
@@ -2625,8 +2606,6 @@ public BigDecimal negate() {
*
* @param mc the context to use.
* @return {@code -this}, rounded as necessary.
* @throws ArithmeticException if the result is inexact but the
* rounding mode is {@code UNNECESSARY}.
* @since 1.5
*/
public BigDecimal negate(MathContext mc) {
@@ -2659,8 +2638,6 @@ public BigDecimal plus() {
* @param mc the context to use.
* @return {@code this}, rounded as necessary. A zero result will
* have a scale of 0.
* @throws ArithmeticException if the result is inexact but the
* rounding mode is {@code UNNECESSARY}.
* @see #round(MathContext)
* @since 1.5
*/
@@ -2842,9 +2819,6 @@ public BigInteger unscaledValue() {
* @param mc the context to use.
* @return a {@code BigDecimal} rounded according to the
* {@code MathContext} settings.
* @throws ArithmeticException if the rounding mode is
* {@code UNNECESSARY} and the
* {@code BigDecimal} operation would require rounding.
* @see #plus(MathContext)
* @since 1.5
*/
@@ -3093,6 +3067,7 @@ public BigDecimal scaleByPowerOfTen(int n) {
*
* @return a numerically equal {@code BigDecimal} with any
* trailing zeros removed.
* @throws ArithmeticException if scale overflows.
* @since 1.5
*/
public BigDecimal stripTrailingZeros() {
@@ -4924,6 +4899,7 @@ private static boolean needIncrement(MutableBigInteger mdivisor, int roundingMod
*
* @return new {@code BigDecimal} with a scale possibly reduced
* to be closed to the preferred scale.
* @throws ArithmeticException if scale overflows.
*/
private static BigDecimal createAndStripZerosToMatchScale(BigInteger intVal, int scale, long preferredScale) {
BigInteger qr[]; // quotient-remainder pair
@@ -4948,6 +4924,7 @@ private static BigDecimal createAndStripZerosToMatchScale(BigInteger intVal, int
*
* @return new {@code BigDecimal} with a scale possibly reduced
* to be closed to the preferred scale.
* @throws ArithmeticException if scale overflows.
*/
private static BigDecimal createAndStripZerosToMatchScale(long compactVal, int scale, long preferredScale) {
while (Math.abs(compactVal) >= 10L && scale > preferredScale) {
ProTip! Use n and p to navigate between commits in a pull request.