commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r383487 - in /jakarta/commons/proper/lang/trunk/src: java/org/apache/commons/lang/math/Fraction.java test/org/apache/commons/lang/math/FractionTest.java
Date Mon, 06 Mar 2006 07:30:00 GMT
Author: bayard
Date: Sun Mar  5 23:29:57 2006
New Revision: 383487

URL: http://svn.apache.org/viewcvs?rev=383487&view=rev
Log:
Fixing -1/1 bug as per #37661

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

Modified: jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/Fraction.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/Fraction.java?rev=383487&r1=383486&r2=383487&view=diff
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/Fraction.java
(original)
+++ jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/Fraction.java
Sun Mar  5 23:29:57 2006
@@ -909,6 +909,8 @@
                 toProperString = "0";
             } else if (numerator == denominator) {
                 toProperString = "1";
+            } else if (numerator == -1 * denominator) {
+                toProperString = "-1";
             } else if ((numerator>0?-numerator:numerator) < -denominator) {
                 // note that we do the magnitude comparison test above with
                 // NEGATIVE (not positive) numbers, since negative numbers

Modified: jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/math/FractionTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/math/FractionTest.java?rev=383487&r1=383486&r2=383487&view=diff
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/math/FractionTest.java
(original)
+++ jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/math/FractionTest.java
Sun Mar  5 23:29:57 2006
@@ -1334,5 +1334,7 @@
 
         f = Fraction.getFraction(-1, 1, Integer.MAX_VALUE);
         assertEquals("-1 1/2147483647", f.toProperString());
+
+        assertEquals("-1", Fraction.getFraction(-1).toProperString());
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message