You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2021/09/27 13:20:19 UTC
[commons-numbers] branch master updated: Correct format string for
FractionException
This is an automated email from the ASF dual-hosted git repository.
aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-numbers.git
The following commit(s) were added to refs/heads/master by this push:
new deed685 Correct format string for FractionException
deed685 is described below
commit deed685de97c005d7e2382649d00e5269e58632a
Author: aherbert <ah...@apache.org>
AuthorDate: Mon Sep 27 14:18:46 2021 +0100
Correct format string for FractionException
{0} is not applicable to String.format. It must use %conversion entries,
in this case %s.
Replace two exception messages for infinite or Nan with a single message
that formats the non-finite value in the message.
Replace 'maximal count' with 'maximum iterations'.
---
.../org/apache/commons/numbers/fraction/ContinuedFraction.java | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/ContinuedFraction.java b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/ContinuedFraction.java
index a01fee8..3db48d6 100644
--- a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/ContinuedFraction.java
+++ b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/ContinuedFraction.java
@@ -126,13 +126,9 @@ public abstract class ContinuedFraction {
final double deltaN = cN * dN;
hN = hPrev * deltaN;
- if (Double.isInfinite(hN)) {
+ if (!Double.isFinite(hN)) {
throw new FractionException(
- "Continued fraction convergents diverged to +/- infinity for value {0}", x);
- }
- if (Double.isNaN(hN)) {
- throw new FractionException(
- "Continued fraction diverged to NaN for value {0}", x);
+ "Continued fraction diverged to %s for value %s", hN, x);
}
if (Math.abs(deltaN - 1) < epsilon) {
@@ -145,7 +141,7 @@ public abstract class ContinuedFraction {
++n;
}
- throw new FractionException("maximal count ({0}) exceeded", maxIterations);
+ throw new FractionException("Maximum iterations (%d) exceeded", maxIterations);
}
/**