harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r787977 - /harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Math.java
Date Wed, 24 Jun 2009 11:13:12 GMT
Author: tellison
Date: Wed Jun 24 11:13:12 2009
New Revision: 787977

URL: http://svn.apache.org/viewvc?rev=787977&view=rev
Log:
Fix for HARMONY-6242 (Math.max(double, double) gives wrong answer when Math.max(-0.0d, 0.0d))

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Math.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=787977&r1=787976&r2=787977&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 Wed Jun
24 11:13:12 2009
@@ -502,10 +502,11 @@
 		/* if either arg is NaN, return NaN */
 		if (d1 != d2)
 			return Double.NaN;
-		/* max( +0.0,-0.0) == +0.0 */
-		if (d1 == 0.0 && (d1 != -0.0d || d2 != -0.0d))
-			return 0.0;
-		return d1;
+		/* max(+0.0,-0.0) == +0.0 */
+	    if (Double.doubleToRawLongBits(d1) == Double.doubleToRawLongBits(-0.0d)) {
+	        return d2;
+	     }
+	     return 0.0d;
 	}
 
     /**
@@ -534,10 +535,11 @@
 		/* if either arg is NaN, return NaN */
 		if (f1 != f2)
 			return Float.NaN;
-		/* max( +0.0,-0.0) == +0.0 */
-		if (f1 == 0.0f && (f1 != -0.0f || f2 != -0.0f))
-			return 0.0f;
-		return f1;
+		/* max(+0.0,-0.0) == +0.0 */
+        if (Float.floatToRawIntBits(f1) == Float.floatToRawIntBits(-0.0f)) {
+            return f2;
+         }
+         return 0.0f;
 	}
 
     /**
@@ -594,10 +596,11 @@
 		/* if either arg is NaN, return NaN */
 		if (d1 != d2)
 			return Double.NaN;
-		/* min( +0.0,-0.0) == -0.0 */
-		if (d1 == 0.0 && (d1 == -0.0d || d2 == -0.0d))
-			return -0.0d;
-		return d1;
+		/* min(+0.0,-0.0) == -0.0 */
+        if (Double.doubleToRawLongBits(d1) == Double.doubleToRawLongBits(-0.0d)) {
+            return -0.0d;
+         }
+         return d2;
 	}
 
     /**
@@ -626,10 +629,11 @@
 		/* if either arg is NaN, return NaN */
 		if (f1 != f2)
 			return Float.NaN;
-		/* min( +0.0,-0.0) == -0.0 */
-		if (f1 == 0.0f	&& (f1 == -0.0f || f2 == -0.0f)) 
-			return -0.0f;
-		return f1;
+		/* min(+0.0,-0.0) == -0.0 */
+        if (Float.floatToRawIntBits(f1) == Float.floatToRawIntBits(-0.0f)) {
+            return -0.0f;
+         }
+         return f2;
 	}
 
     /**



Mime
View raw message