aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/lang
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/java/lang')
-rw-r--r--libjava/java/lang/Math.java10
-rw-r--r--libjava/java/lang/StrictMath.java4
2 files changed, 10 insertions, 4 deletions
diff --git a/libjava/java/lang/Math.java b/libjava/java/lang/Math.java
index cb5f70b..e41eca7 100644
--- a/libjava/java/lang/Math.java
+++ b/libjava/java/lang/Math.java
@@ -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;
}
}
diff --git a/libjava/java/lang/StrictMath.java b/libjava/java/lang/StrictMath.java
index bacc291..9411a9b 100644
--- a/libjava/java/lang/StrictMath.java
+++ b/libjava/java/lang/StrictMath.java
@@ -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;
}
/**