From ce57ab760f69de6db452def7ffbf5b114a2d8694 Mon Sep 17 00:00:00 2001 From: mark Date: Fri, 10 Mar 2006 21:46:48 +0000 Subject: Imported GNU Classpath 0.90 * scripts/makemake.tcl: Set gnu/java/awt/peer/swing to ignore. * gnu/classpath/jdwp/VMFrame.java (SIZE): New constant. * java/lang/VMCompiler.java: Use gnu.java.security.hash.MD5. * java/lang/Math.java: New override file. * java/lang/Character.java: Merged from Classpath. (start, end): Now 'int's. (canonicalName): New field. (CANONICAL_NAME, NO_SPACES_NAME, CONSTANT_NAME): New constants. (UnicodeBlock): Added argument. (of): New overload. (forName): New method. Updated unicode blocks. (sets): Updated. * sources.am: Regenerated. * Makefile.in: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@111942 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/classpath/java/lang/Math.java | 351 +++++++++++++++++++++++++++++++--- 1 file changed, 326 insertions(+), 25 deletions(-) (limited to 'libjava/classpath/java/lang/Math.java') diff --git a/libjava/classpath/java/lang/Math.java b/libjava/classpath/java/lang/Math.java index 08081e2523a..d7c8aa1c433 100644 --- a/libjava/classpath/java/lang/Math.java +++ b/libjava/classpath/java/lang/Math.java @@ -1,5 +1,5 @@ -/* java.lang.Math -- common mathematical functions, native allowed - Copyright (C) 1998, 2001, 2002, 2003 Free Software Foundation, Inc. +/* java.lang.Math -- common mathematical functions, native allowed (VMMath) + Copyright (C) 1998, 2001, 2002, 2003, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -52,25 +52,33 @@ import java.util.Random; * @author Paul Fisher * @author John Keiser * @author Eric Blake (ebb9@email.byu.edu) + * @author Andrew John Hughes (gnu_andrew@member.fsf.org) * @since 1.0 */ public final class Math { - /** - * Math is non-instantiable - */ - private Math() - { - } + // FIXME - This is here because we need to load the "javalang" system + // library somewhere late in the bootstrap cycle. We cannot do this + // from VMSystem or VMRuntime since those are used to actually load + // the library. This is mainly here because historically Math was + // late enough in the bootstrap cycle to start using System after it + // was initialized (called from the java.util classes). static { if (Configuration.INIT_LOAD_LIBRARY) { - System.loadLibrary("javalang"); + System.loadLibrary("javalang"); } } + /** + * Math is non-instantiable + */ + private Math() + { + } + /** * A random number generator, initialized on first use. */ @@ -298,7 +306,10 @@ public final class Math * @param a the angle (in radians) * @return sin(a) */ - public static native double sin(double a); + public static double sin(double a) + { + return VMMath.sin(a); + } /** * The trigonometric function cos. The cosine of NaN or infinity is @@ -307,7 +318,10 @@ public final class Math * @param a the angle (in radians) * @return cos(a) */ - public static native double cos(double a); + public static double cos(double a) + { + return VMMath.cos(a); + } /** * The trigonometric function tan. The tangent of NaN or infinity @@ -317,7 +331,10 @@ public final class Math * @param a the angle (in radians) * @return tan(a) */ - public static native double tan(double a); + public static double tan(double a) + { + return VMMath.tan(a); + } /** * The trigonometric function arcsin. The range of angles returned @@ -328,7 +345,10 @@ public final class Math * @param a the sin to turn back into an angle * @return arcsin(a) */ - public static native double asin(double a); + public static double asin(double a) + { + return VMMath.asin(a); + } /** * The trigonometric function arccos. The range of angles returned @@ -339,7 +359,10 @@ public final class Math * @param a the cos to turn back into an angle * @return arccos(a) */ - public static native double acos(double a); + public static double acos(double a) + { + return VMMath.acos(a); + } /** * The trigonometric function arcsin. The range of angles returned @@ -351,7 +374,10 @@ public final class Math * @return arcsin(a) * @see #atan2(double, double) */ - public static native double atan(double a); + public static double atan(double a) + { + return VMMath.atan(a); + } /** * A special version of the trigonometric function arctan, for @@ -400,7 +426,10 @@ public final class Math * @return theta in the conversion of (x, y) to (r, theta) * @see #atan(double) */ - public static native double atan2(double y, double x); + public static double atan2(double y, double x) + { + return VMMath.atan2(y,x); + } /** * Take ea. The opposite of log(). If the @@ -414,7 +443,10 @@ public final class Math * @see #log(double) * @see #pow(double, double) */ - public static native double exp(double a); + public static double exp(double a) + { + return VMMath.exp(a); + } /** * Take ln(a) (the natural log). The opposite of exp(). If the @@ -430,7 +462,10 @@ public final class Math * @return the natural log of a * @see #exp(double) */ - public static native double log(double a); + public static double log(double a) + { + return VMMath.log(a); + } /** * Take a square root. If the argument is NaN or negative, the result is @@ -438,13 +473,18 @@ public final class Math * infinity; and if the result is either zero, the result is the same. * This is accurate within the limits of doubles. * - *

For other roots, use pow(a, 1 / rootNumber). + *

For a cube root, use cbrt. For other roots, use + * pow(a, 1 / rootNumber).

* * @param a the numeric argument * @return the square root of the argument + * @see #cbrt(double) * @see #pow(double, double) */ - public static native double sqrt(double a); + public static double sqrt(double a) + { + return VMMath.sqrt(a); + } /** * Raise a number to a power. Special cases: