This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
RE: Patch: FYI: Math/StrictMath merge
- From: "Boehm, Hans" <hans_boehm at hp dot com>
- To: GCC libjava patches <java-patches at gcc dot gnu dot org>
- Cc: "'tromey at redhat dot com'" <tromey at redhat dot com>
- Date: Wed, 8 Oct 2003 16:09:31 -0700
- Subject: RE: Patch: FYI: Math/StrictMath merge
Could someone explain why this is a good idea? It seems to replace one
multiplication by two, and it introduces additional overflow possibilities.
I'd be willing to accept both if it improves accuracy. What's the argument
that it does?
Hans
> 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
...
> @@ -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;
> }
>
> /**
>