harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r814620 - 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 Mon, 14 Sep 2009 12:43:29 GMT
Author: tellison
Date: Mon Sep 14 12:43:29 2009
New Revision: 814620

URL: http://svn.apache.org/viewvc?rev=814620&view=rev
Log:
Apply fix for HARMONY-6339 ([classlib] [math] Sample test case showing Math differences)

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=814620&r1=814619&r2=814620&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 Mon Sep
14 12:43:29 2009
@@ -246,9 +246,7 @@
      *            the value whose closest integer value has to be computed.
      * @return the ceiling of the argument.
      */
-    public static double ceil(double d) {
-        return -floor(-d);
-    }
+    public static native double ceil(double d);
 
     /**
      * Returns the closest double approximation of the cosine of the argument.
@@ -348,13 +346,7 @@
      *            the value whose closest integer value has to be computed.
      * @return the floor of the argument.
      */
-    public static double floor(double d) {
-        if (Double.isNaN(d) || Double.isInfinite(d) || d == 0) {
-            return d;
-        }
-        double res = (long) d;
-        return d > 0 || res == d ? res : res - 1;
-    }
+    public static native double floor(double d);
 
     /**
      * Returns {@code sqrt(}<i>{@code x}</i><sup>{@code 2}</sup>{@code
+} <i>
@@ -735,13 +727,7 @@
      *            the value to be rounded.
      * @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 && res % 2 != 0 ? res - 1 : res;
-    }
+    public static native double rint(double d);
 
     /**
      * Returns the result of rounding the argument to an integer. The result is

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=814620&r1=814619&r2=814620&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
Mon Sep 14 12:43:29 2009
@@ -244,13 +244,11 @@
     /**
      * @tests java.lang.Math#floor(double)
      */
-	public void test_floorD() {
-		// Test for method double java.lang.Math.floor(double)
-                assertEquals("Incorrect floor for double",
-                             78, Math.floor(78.89), 0);
-		assertEquals("Incorrect floor for double",
-                             -79, Math.floor(-78.89), 0);
-	}
+    public void test_floorD() {
+        assertEquals("Incorrect floor for double", 78, Math.floor(78.89), 0);
+        assertEquals("Incorrect floor for double", -79, Math.floor(-78.89), 0);
+        assertEquals("floor large double", 3.7314645675925406E19, Math.floor(3.7314645675925406E19),0);
+    }
     
     /**
      * @tests java.lang.Math#hypot(double, double)



Mime
View raw message