StrictMath.java (toDegrees): Multiply before dividing.
authorTom Tromey <tromey@gcc.gnu.org>
Wed, 8 Oct 2003 19:00:21 +0000 (19:00 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Wed, 8 Oct 2003 19:00:21 +0000 (19:00 +0000)
* java/lang/StrictMath.java (toDegrees): Multiply before
dividing.
(toRadians): Likewise.

2003-10-08  C. Brian Jones  <cbj@gnu.org>

* java/lang/Math.java
(toRadians): multiply before dividing to reduce decimal error
(toDegrees): ditto

From-SVN: r72238

libjava/ChangeLog
libjava/java/lang/Math.java
libjava/java/lang/StrictMath.java

index 2812d333f2f1fc4d1621f65f349a47136eae7c36..2d76caebf5e4b9dcdfb56404c38ab67d8e574cc5 100644 (file)
@@ -1,3 +1,15 @@
+2003-10-08  Tom Tromey  <tromey@redhat.com>
+
+       * java/lang/StrictMath.java (toDegrees): Multiply before
+       dividing.
+       (toRadians): Likewise.
+
+2003-10-08  C. Brian Jones  <cbj@gnu.org>
+
+       * java/lang/Math.java
+       (toRadians): multiply before dividing to reduce decimal error
+       (toDegrees): ditto
+
 2003-10-08  Michael Koch  <konqueror@gmx.de>
 
        * gnu/gcj/protocol/core/Connection.java,
index cb5f70b1cfbef427ff770f3f3b77437d4864b091..e41eca7ce1a1a4327bd2a9c8c8e5e8bb0a48d811 100644 (file)
@@ -575,6 +575,9 @@ public final class Math
    */
   public static int round(float a)
   {
+    // this check for NaN, from JLS 15.21.1, saves a method call
+    if (a != a)
+      return 0;
     return (int) floor(a + 0.5f);
   }
 
@@ -591,6 +594,9 @@ public final class Math
    */
   public static long round(double a)
   {
+    // this check for NaN, from JLS 15.21.1, saves a method call
+    if (a != a)
+      return 0;
     return (long) floor(a + 0.5d);
   }
 
@@ -624,7 +630,7 @@ public final class Math
    */
   public static double toRadians(double degrees)
   {
-    return degrees * (PI / 180);
+    return (degrees * PI) / 180;
   }
 
   /**
@@ -638,6 +644,6 @@ public final class Math
    */
   public static double toDegrees(double rads)
   {
-    return rads * (180 / PI);
+    return (rads * 180) / PI;
   }
 }
index bacc291faa5c116acd0ac0de269de427a52bc5d0..9411a9bd4042b891facdde97ae17b896bdab9217 100644 (file)
@@ -1213,7 +1213,7 @@ public final strictfp class StrictMath
    */
   public static double toRadians(double degrees)
   {
-    return degrees * (PI / 180);
+    return (degrees * PI) / 180;
   }
 
   /**
@@ -1226,7 +1226,7 @@ public final strictfp class StrictMath
    */
   public static double toDegrees(double rads)
   {
-    return rads * (180 / PI);
+    return (rads * 180) / PI;
   }
 
   /**