Commit d7912744 by Tom Tromey

StrictMath.java (toDegrees): Multiply before dividing.

	* 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
parent f06c07c7
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> 2003-10-08 Michael Koch <konqueror@gmx.de>
* gnu/gcj/protocol/core/Connection.java, * gnu/gcj/protocol/core/Connection.java,
......
...@@ -575,6 +575,9 @@ public final class Math ...@@ -575,6 +575,9 @@ public final class Math
*/ */
public static int round(float a) 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); return (int) floor(a + 0.5f);
} }
...@@ -591,6 +594,9 @@ public final class Math ...@@ -591,6 +594,9 @@ public final class Math
*/ */
public static long round(double a) 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); return (long) floor(a + 0.5d);
} }
...@@ -624,7 +630,7 @@ public final class Math ...@@ -624,7 +630,7 @@ public final class Math
*/ */
public static double toRadians(double degrees) public static double toRadians(double degrees)
{ {
return degrees * (PI / 180); return (degrees * PI) / 180;
} }
/** /**
...@@ -638,6 +644,6 @@ public final class Math ...@@ -638,6 +644,6 @@ public final class Math
*/ */
public static double toDegrees(double rads) public static double toDegrees(double rads)
{ {
return rads * (180 / PI); return (rads * 180) / PI;
} }
} }
...@@ -1213,7 +1213,7 @@ public final strictfp class StrictMath ...@@ -1213,7 +1213,7 @@ public final strictfp class StrictMath
*/ */
public static double toRadians(double degrees) public static double toRadians(double degrees)
{ {
return degrees * (PI / 180); return (degrees * PI) / 180;
} }
/** /**
...@@ -1226,7 +1226,7 @@ public final strictfp class StrictMath ...@@ -1226,7 +1226,7 @@ public final strictfp class StrictMath
*/ */
public static double toDegrees(double rads) public static double toDegrees(double rads)
{ {
return rads * (180 / PI); return (rads * 180) / PI;
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment