You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2019/11/06 15:09:33 UTC

[commons-numbers] branch master updated (a643546 -> 74a4d33)

This is an automated email from the ASF dual-hosted git repository.

erans pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-numbers.git.


    from a643546  Unit tests.
     new 15e2c1a  Also report issues tagged as "Implemented".
     new 3af49d4  Formatting nits.
     new 2b478e4  Javadoc.
     new 74a4d33  Use "final".

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/commons/numbers/fraction/Fraction.java  | 34 +++++++++-------------
 pom.xml                                            |  2 +-
 2 files changed, 15 insertions(+), 21 deletions(-)


[commons-numbers] 01/04: Also report issues tagged as "Implemented".

Posted by er...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

erans pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-numbers.git

commit 15e2c1aaee86e3a7f7ba1871b0f462aa416359d3
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
AuthorDate: Wed Nov 6 15:23:00 2019 +0100

    Also report issues tagged as "Implemented".
    
    Thanks to Alex Herbert.
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 4bb5963..0dabcbf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -333,7 +333,7 @@
           <columnNames>Fix Version,Key,Component,Summary,Type,Resolution,Status</columnNames>
           <!-- Sort cols in natural order when using JQL for JIRA 5.1 -->
           <sortColumnNames>Fix Version DESC,Type,Key DESC</sortColumnNames>
-          <resolutionIds>Fixed</resolutionIds>
+          <resolutionIds>Fixed,Implemented</resolutionIds>
           <statusIds>Resolved,Closed</statusIds>
           <!-- Don't include sub-task -->
           <typeIds>Bug,New Feature,Task,Improvement,Wish,Test</typeIds>


[commons-numbers] 04/04: Use "final".

Posted by er...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

erans pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-numbers.git

commit 74a4d3353600d3099e15ba26257344d7c5296f87
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
AuthorDate: Wed Nov 6 16:08:28 2019 +0100

    Use "final".
---
 .../java/org/apache/commons/numbers/fraction/Fraction.java     | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java
index 5568bff..1f99079 100644
--- a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java
+++ b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java
@@ -116,7 +116,7 @@ public class Fraction
                 throw new FractionException(FractionException.ERROR_CONVERSION, value, p2, q2);
             }
 
-            double convergent = (double)p2 / (double)q2;
+            final double convergent = (double)p2 / (double)q2;
             if (n < maxIterations &&
                 Math.abs(convergent - value) > epsilon &&
                 q2 < maxDenominator) {
@@ -280,8 +280,8 @@ public class Fraction
      */
     @Override
     public int compareTo(Fraction object) {
-        long nOd = ((long) numerator) * object.denominator;
-        long dOn = ((long) denominator) * object.numerator;
+        final long nOd = ((long) numerator) * object.denominator;
+        final long dOn = ((long) denominator) * object.numerator;
         return nOd < dOn ? -1 :
             nOd > dOn ? 1 :
             0;
@@ -541,8 +541,8 @@ public class Fraction
 
         // knuth 4.5.1
         // Make sure we don't overflow unless the result *must* overflow.
-        int d1 = ArithmeticUtils.gcd(numerator, fraction.denominator);
-        int d2 = ArithmeticUtils.gcd(fraction.numerator, denominator);
+        final int d1 = ArithmeticUtils.gcd(numerator, fraction.denominator);
+        final int d2 = ArithmeticUtils.gcd(fraction.numerator, denominator);
         return of(Math.multiplyExact(numerator / d1, fraction.numerator / d2),
                   Math.multiplyExact(denominator / d2, fraction.denominator / d1));
     }


[commons-numbers] 02/04: Formatting nits.

Posted by er...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

erans pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-numbers.git

commit 3af49d48c34de899e0110990dae7e5bc3a6554e6
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
AuthorDate: Wed Nov 6 16:03:16 2019 +0100

    Formatting nits.
---
 .../java/org/apache/commons/numbers/fraction/Fraction.java     | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java
index 228f236..8101a8d 100644
--- a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java
+++ b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java
@@ -115,17 +115,21 @@ public class Fraction
             p2 = (a1 * p1) + p0;
             q2 = (a1 * q1) + q0;
 
-            if ((Math.abs(p2) > overflow) || (Math.abs(q2) > overflow)) {
+            if (Math.abs(p2) > overflow ||
+                Math.abs(q2) > overflow) {
                 // in maxDenominator mode, if the last fraction was very close to the actual value
                 // q2 may overflow in the next iteration; in this case return the last one.
-                if (epsilon == 0.0 && Math.abs(q1) < maxDenominator) {
+                if (epsilon == 0.0 &&
+                    Math.abs(q1) < maxDenominator) {
                     break;
                 }
                 throw new FractionException(FractionException.ERROR_CONVERSION, value, p2, q2);
             }
 
             double convergent = (double)p2 / (double)q2;
-            if (n < maxIterations && Math.abs(convergent - value) > epsilon && q2 < maxDenominator) {
+            if (n < maxIterations &&
+                Math.abs(convergent - value) > epsilon &&
+                q2 < maxDenominator) {
                 p0 = p1;
                 p1 = p2;
                 q0 = q1;


[commons-numbers] 03/04: Javadoc.

Posted by er...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

erans pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-numbers.git

commit 2b478e4e315c54b0b68d322579e80e4a4deba40b
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
AuthorDate: Wed Nov 6 16:05:42 2019 +0100

    Javadoc.
---
 .../java/org/apache/commons/numbers/fraction/Fraction.java | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java
index 8101a8d..5568bff 100644
--- a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java
+++ b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java
@@ -28,29 +28,19 @@ public class Fraction
     implements Comparable<Fraction>,
                NativeOperators<Fraction>,
                Serializable {
-
     /** A fraction representing "1". */
     public static final Fraction ONE = new Fraction(1, 1);
-
     /** A fraction representing "0". */
     public static final Fraction ZERO = new Fraction(0, 1);
-
     /** Serializable version identifier */
     private static final long serialVersionUID = 20190701L;
-
     /** Parameter name for fraction (to satisfy checkstyle). */
     private static final String PARAM_NAME_FRACTION = "fraction";
-
     /** The default epsilon used for convergence. */
     private static final double DEFAULT_EPSILON = 1e-5;
-
-    /** The denominator of this fraction reduced to lowest terms. Always positive. */
+    /** The denominator of this fraction reduced to lowest terms. */
     private final int denominator;
-
-    /**
-     * The numerator of this fraction reduced to lowest terms. Negative if this
-     * fraction's value is negative.
-     */
+    /** The numerator of this fraction reduced to lowest terms. */
     private final int numerator;
 
     /**