Math

Name

Math

Synopsis

Description

The Math class contains constants for the mathematical values pi and e. The class also defines methods that compute various mathematical functions, such as trigonometric and exponential functions. All of these constants and methods are static. In other words, it is not necessary to create an instance of the Math class in order to use its constants and methods. In fact, the Math class does not define any public constructors, so it cannot be instantiated.

To ensure that the methods in this class return consistent results under different implementations of Java, all of the methods use the algorithms from the well-known Freely-Distributable Math Library package, fdlibm. This package is part of the network library netlib. The library can be obtained through the URL http://netlib.att.com. The algorithms used in this class are from the version of fdlibm dated January 4. fdlibm provides more than one definition for some functions. In those cases, the "IEEE 754 core function" version is used.

Class Summary

public final class java.lang.Math extends java.lang.Object {
 // Constants public static final double E;
public static final double PI; // 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 native double acos(double a);
public static native double asin(double a);
public static native double atan(double a);
public static native double atan2(double a, double b);
public static native double ceil(double a);
public static native double cos(double a);
public static native double exp(double a);
public static native double floor(double a);
public static native double IEEEremainder(double f1, double f2);
public static native double log(double a);
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 native double pow(double a, double b);
public static synchronized double random();
public static native double rint(double a);
public static int round(float a);
public static long round(double a);
public static native double sin(double a);
public static native double sqrt(double a);
public static native double tan(double a);
}

Constants

E

public static final double E = 2.7182818284590452354

PI

public static final double PI = 3.14159265358979323846

Class Methods

abs

public static double abs(double a)

public static float abs(float a)

public static int abs(int a)

public static long abs(long a)

acos

public static native double acos(double a)

asin

public static native double asin(double a)

atan

public static native double atan(double a)

atan2

public static native double atan2(double a, double b)

ceil

public static native double ceil(double a)

cos

public static native double cos(double a)

exp

public static native double exp(double a)

floor

public static native double floor(double a)

IEEEremainder

public static native double IEEEremainder(double a, double b)

log

public static native double log(double a)

max

public static double max(double a, double b)

public static float max(float a, float b)

public static int max(int a, int b)

public static long max(long a, long b)

min

public static double min(double a, double b)

public static float min(float a, float b)

public static int min(int a, int b)

public static long min(long a, long b)

pow

public static native double pow(double a, double b)

random

public static synchronized double random()

rint

public static native double rint(double a)

round

public static long round(double a)

public static int round(float a)

sin

public static native double sin(double a)

sqrt

public static native double sqrt(double a)

tan

public static native double tan(double a)

Inherited Methods

Method Inherited From Method Inherited From
clone() Object equals(Object) Object
finalize() Object getClass() Object
hashCode() Object notify() Object
notifyAll() Object toString() Object
wait() Object wait(long) Object
wait(long, int) Object

See Also

Double; Float; Floating-point literals; Floating-point types; Integer; Integer literals; Integer types; Long; Object