Index: modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/MathTest.java =================================================================== --- modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/MathTest.java (revision 628638) +++ modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/MathTest.java (working copy) @@ -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); } /** Index: modules/luni/src/main/java/java/lang/Math.java =================================================================== --- modules/luni/src/main/java/java/lang/Math.java (revision 628638) +++ modules/luni/src/main/java/java/lang/Math.java (working copy) @@ -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; } /**