Team LiB
Previous Section Next Section

Mathjava.lang

Java 1.0

This class defines constants for the mathematical values e and and defines static methods for floating-point trigonometry, exponentiation, and other operations. It is the equivalent of the C <math.h> functions. It also contains methods for computing minimum and maximum values and for generating pseudorandom numbers.

Most methods of Math operate on float and double floating-point values. Remember that these values are only approximations of actual real numbers. To allow implementations to take full advantage of the floating-point capabilities of a native platform, the methods of Math are not required to return exactly the same values on all platforms. In other words, the results returned by different implementations may differ slightly in the least-significant bits. As of Java 1.3, applications that require strict platform-independence of results should use StrictMath instead.

Java 5.0 adds several methods including log10( ) to compute the base-ten logarithm, cbrt( ) to compute the cube root of a number, and signum( ) to compute the sign of a number as well as sinh( ) , cosh( ), and tanh( ) hyperbolic trigonometric functions.

public final class Math {
// No Constructor
// Public Constants
     public static final double E;         =2.718281828459045
     public static final double PI;        =3.141592653589793
// Public Class Methods
     public static int abs(int a);  
     public static long abs(long a);  
     public static float abs(float a);  
     public static double abs(double a);  
     public static double acos(double a);  
     public static double asin(double a);  
     public static double atan(double a);  
     public static double atan2(double y, double x);  
5.0  public static double cbrt(double a);  
     public static double ceil(double a);  
     public static double cos(double a);  
5.0  public static double cosh(double x);  
     public static double exp(double a);  
5.0  public static double expm1(double x);  
     public static double floor(double a);  
5.0  public static double hypot(double x, double y);  
     public static double IEEEremainder(double f1, double f2);  
     public static double log(double a);  
5.0  public static double log10(double a);  
5.0  public static double log1p(double x);  
     public static int max(int a, int b);  
     public static long max(long a, long b);  
     public static float max(float a, float b);  
     public static double max(double a, double b);  
     public static int min(int a, int b);  
     public static long min(long a, long b);  
     public static float min(float a, float b);  
     public static double min(double a, double b);  
     public static double pow(double a, double b);  
     public static double random( );  
     public static double rint(double a);  
     public static int round(float a);  
     public static long round(double a);  
5.0  public static float signum(float f);  
5.0  public static double signum(double d);  
     public static double sin(double a);  
5.0  public static double sinh(double x);  
     public static double sqrt(double a);  
     public static double tan(double a);  
5.0  public static double tanh(double x);  
1.2  public static double toDegrees(double angrad);  
1.2  public static double toRadians(double angdeg);  
5.0  public static float ulp(float f);  
5.0  public static double ulp(double d);  
}

    Team LiB
    Previous Section Next Section