harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r793179 - 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 Sat, 11 Jul 2009 15:14:30 GMT
Author: tellison
Date: Sat Jul 11 15:14:30 2009
New Revision: 793179

URL: http://svn.apache.org/viewvc?rev=793179&view=rev
Log:
Fix for HARMONY-6268 ([classlib][luni] Math.min fails when comparing doubles and floats with
the same values)

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=793179&r1=793178&r2=793179&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 Sat Jul
11 15:14:30 2009
@@ -505,7 +505,8 @@
             return Double.NaN;
         }
         /* max(+0.0,-0.0) == +0.0 */
-        if (Double.doubleToRawLongBits(d1) != Double.doubleToRawLongBits(0.0d)) {
+        /* 0 == Double.doubleToRawLongBits(0.0d) */
+        if (Double.doubleToRawLongBits(d1) != 0) {
             return d2;
         }
         return 0.0d;
@@ -541,7 +542,8 @@
             return Float.NaN;
         }
         /* max(+0.0,-0.0) == +0.0 */
-        if (Float.floatToRawIntBits(f1) != Float.floatToRawIntBits(0.0f)) {
+        /* 0 == Float.floatToRawIntBits(0.0f) */
+        if (Float.floatToRawIntBits(f1) != 0) {
             return f2;
         }
         return 0.0f;
@@ -605,7 +607,8 @@
             return Double.NaN;
         }
         /* min(+0.0,-0.0) == -0.0 */
-        if (Double.doubleToRawLongBits(d1) != Double.doubleToRawLongBits(0.0d)) {
+        /* 0x8000000000000000L == Double.doubleToRawLongBits(-0.0d) */
+        if (Double.doubleToRawLongBits(d1) == 0x8000000000000000L) {
             return -0.0d;
         }
         return d2;
@@ -641,7 +644,8 @@
             return Float.NaN;
         }
         /* min(+0.0,-0.0) == -0.0 */
-        if (Float.floatToRawIntBits(f1) != Float.floatToRawIntBits(0.0f)) {
+        /* 0x80000000 == Float.floatToRawIntBits(-0.0f) */
+        if (Float.floatToRawIntBits(f1) == 0x80000000) {
             return -0.0f;
         }
         return f2;

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=793179&r1=793178&r2=793179&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
Sat Jul 11 15:14:30 2009
@@ -458,6 +458,7 @@
 				2.0, Math.min(2.0, 1908897.6000089), 0D);
 		assertEquals("Incorrect double min value", -1908897.6000089, Math.min(-2.0,
 				-1908897.6000089), 0D);
+		assertEquals("Incorrect double min value", 1.0d, Math.min(1.0d, 1.0d));
 		
 	    // Compare toString representations here since -0.0 = +0.0, and
         // NaN != NaN and we need to distinguish
@@ -486,7 +487,8 @@
 				Math.min(2.0f, 1908897.600f) == 2.0f);
 		assertTrue("Incorrect float min value",
 				Math.min(-2.0f, -1908897.600f) == -1908897.600f);
-		
+		assertEquals("Incorrect float min value", 1.0f, Math.min(1.0f, 1.0f));
+
         // Compare toString representations here since -0.0 = +0.0, and
         // NaN != NaN and we need to distinguish
         assertEquals("Min failed for NaN",



Mime
View raw message