commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r598705 - /commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/Fraction.java
Date Tue, 27 Nov 2007 17:25:02 GMT
Author: mbenson
Date: Tue Nov 27 09:24:59 2007
New Revision: 598705

URL: http://svn.apache.org/viewvc?rev=598705&view=rev
Log:
avoid unnecessary work; remove commented code

Modified:
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/Fraction.java

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/Fraction.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/Fraction.java?rev=598705&r1=598704&r2=598705&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/Fraction.java (original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/Fraction.java Tue Nov
27 09:24:59 2007
@@ -567,11 +567,14 @@
      * @return the greatest common divisor, never zero
      */
     private static int greatestCommonDivisor(int u, int v) {
+        //if either op. is abs 0 or 1, return 1:
+        if (Math.abs(u) <= 1 || Math.abs(v) <= 1) {
+            return 1;
+        }
         // keep u and v negative, as negative integers range down to
         // -2^31, while positive numbers can only be as large as 2^31-1
         // (i.e. we can't necessarily negate a negative number without
         // overflow)
-        /* assert u!=0 && v!=0; */
         if (u>0) { u=-u; } // make u negative
         if (v>0) { v=-v; } // make v negative
         // B1. [Find power of 2]



Mime
View raw message