Patch: FYI: Math/StrictMath merge

Tom Tromey tromey@redhat.com
Wed Oct 8 18:58:00 GMT 2003


I'm checking this in on the trunk.

This re-merges Math and StrictMath with Classpath.

Tom

Index: ChangeLog
from  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

Index: java/lang/Math.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/Math.java,v
retrieving revision 1.6
diff -u -r1.6 Math.java
--- java/lang/Math.java 26 Aug 2003 23:14:07 -0000 1.6
+++ java/lang/Math.java 8 Oct 2003 18:57:42 -0000
@@ -575,6 +575,9 @@
    */
   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 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 static double toRadians(double degrees)
   {
-    return degrees * (PI / 180);
+    return (degrees * PI) / 180;
   }
 
   /**
@@ -638,6 +644,6 @@
    */
   public static double toDegrees(double rads)
   {
-    return rads * (180 / PI);
+    return (rads * 180) / PI;
   }
 }
Index: java/lang/StrictMath.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/StrictMath.java,v
retrieving revision 1.2
diff -u -r1.2 StrictMath.java
--- java/lang/StrictMath.java 26 Aug 2003 23:14:07 -0000 1.2
+++ java/lang/StrictMath.java 8 Oct 2003 18:57:43 -0000
@@ -1213,7 +1213,7 @@
    */
   public static double toRadians(double degrees)
   {
-    return degrees * (PI / 180);
+    return (degrees * PI) / 180;
   }
 
   /**
@@ -1226,7 +1226,7 @@
    */
   public static double toDegrees(double rads)
   {
-    return rads * (180 / PI);
+    return (rads * 180) / PI;
   }
 
   /**



More information about the Java-patches mailing list