harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcfi...@apache.org
Subject svn commit: r629108 - in /harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/lang/Math.java test/api/common/org/apache/harmony/luni/tests/java/lang/MathTest.java
Date Tue, 19 Feb 2008 14:35:04 GMT
Author: mcfirst
Date: Tue Feb 19 06:35:02 2008
New Revision: 629108

URL: http://svn.apache.org/viewvc?rev=629108&view=rev
Log:
Applied patch from HARMONY-5501 [classlib][luni] regression in Math.rint after r620463

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Math.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/MathTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Math.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Math.java?rev=629108&r1=629107&r2=629108&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Math.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Math.java Tue Feb
19 06:35:02 2008
@@ -449,8 +449,11 @@
 	 * @return the closest integer to the argument (as a double).
 	 */
 	public static double rint(double d) {
+	    if(d == +0.0d || d == -0.0d) {
+	        return d;
+	    }
             double res = floor(d + 0.5d);
-            return res - d == 0.5d && d > 0 ? res - 1 : res;  
+            return res - d == 0.5d && res%2 != 0 ? res - 1 : res;
         }
 
 	/**

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/MathTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/MathTest.java?rev=629108&r1=629107&r2=629108&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/MathTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/MathTest.java
Tue Feb 19 06:35:02 2008
@@ -496,6 +496,10 @@
 				2.0, Math.rint(2.1), 0D);
 		assertTrue("Failed to round properly " + 2.5 + " to even", Math
 				.rint(2.5) == 2.0);
+                assertTrue("Failed to round properly " + (+0.0d),
+                        Math.rint(+0.0d) == +0.0d);
+                assertTrue("Failed to round properly " + (-0.0d),
+                        Math.rint(-0.0d) == -0.0d);
 	}
 
 	/**



Mime
View raw message