|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--java.lang.Math
Helper class containing useful mathematical functions and constants.
Note that angles are specified in radians. Conversion functions are provided for your convenience.
| Field Summary | |
static double |
E
The mathematical constant e. |
static double |
NaN
|
static double |
NEGATIVE_INFINITY
|
static double |
PI
The mathematical constant pi. |
static double |
POSITIVE_INFINITY
|
| Constructor Summary | |
Math()
|
|
| Method Summary | |
static double |
abs(double a)
Take the absolute value of the argument. |
static int |
abs(int a)
Take the absolute value of the argument. |
static long |
abs(long a)
Take the absolute value of the argument. |
static double |
acos(double x)
The trigonometric function arccos. |
static double |
asin(double x)
The trigonometric function arcsin. |
static double |
atan(double x)
The trigonometric function arctan. |
static double |
atan2(double y,
double x)
A special version of the trigonometric function arctan. |
static double |
ceil(double x)
Take the nearest integer that is that is greater than or equal to the argument. |
static double |
cos(double x)
The trigonometric function cos. |
static double |
exp(double x)
Take ex. |
static double |
floor(double x)
Take the nearest integer that is that is less than or equal to the argument. |
static double |
IEEEremainder(double x,
double y)
Get the floating point remainder on two numbers, which really does the following: Takes x/y and finds the nearest integer n to the quotient. |
static boolean |
isNaN(double d)
|
static double |
log(double x)
Take ln(x) (the natural log). |
static double |
max(double a,
double b)
Return whichever argument is larger. |
static int |
max(int a,
int b)
Return whichever argument is larger. |
static long |
max(long a,
long b)
Return whichever argument is larger. |
static double |
min(double a,
double b)
Return whichever argument is smaller. |
static int |
min(int a,
int b)
Return whichever argument is smaller. |
static long |
min(long a,
long b)
Return whichever argument is smaller. |
static double |
pow(double x,
double y)
Take a number to a power. |
static double |
rint(double x)
Take the nearest integer to the argument. |
static long |
round(double a)
Take the nearest integer to the argument. |
static double |
sin(double x)
The trigonometric function sin. |
static double |
sqrt(double x)
Take a square root. |
static double |
tan(double x)
The trigonometric function tan. |
static double |
toDegrees(double rads)
Convert from radians to degrees. |
static double |
toRadians(double degrees)
Convert from degrees to radians. |
| Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
toString,
wait,
wait |
| Field Detail |
public static final double NaN
public static final double POSITIVE_INFINITY
public static final double NEGATIVE_INFINITY
public static final double E
log(double),
exp(double)public static final double PI
| Constructor Detail |
public Math()
| Method Detail |
public static int abs(int a)
Note that the largest negative value (Integer.MIN_VALUE) cannot be made positive. In this case, because of the rules of negation in a computer, MIN_VALUE is what will be returned. This is a negative value. You have been warned.
a - the number to take the absolute value of.public static long abs(long a)
Note that the largest negative value (Long.MIN_VALUE) cannot be made positive. In this case, because of the rules of negation in a computer, MIN_VALUE is what will be returned. This is a negative value. You have been warned.
a - the number to take the absolute value of.public static double abs(double a)
a - the number to take the absolute value of.
public static int min(int a,
int b)
a - the first numberb - a second number
public static long min(long a,
long b)
a - the first numberb - a second number
public static double min(double a,
double b)
a - the first numberb - a second number
public static int max(int a,
int b)
a - the first numberb - a second number
public static long max(long a,
long b)
a - the first numberb - a second number
public static double max(double a,
double b)
a - the first numberb - a second numberpublic static double sin(double x)
x - the angle (in radians).public static double cos(double x)
x - the angle (in radians).public static double tan(double x)
x - the angle (in radians).public static double asin(double x)
x - the sin to turn back into an angle.public static double acos(double x)
x - the cos to turn back into an angle.public static double atan(double x)
x - the tan to turn back into an angle.atan2(double,double)
public static double atan2(double y,
double x)
atan().y - the y positionx - the x positionatan(double)public static double exp(double x)
log().x - the number to raise to the power.log(double),
pow(double,double)public static double log(double x)
exp().
Note that the way to get logb(a) is to do this:
ln(a) / ln(b).x - the number to take the natural log of.x.exp(double)public static double sqrt(double x)
x - the numeric argumentpow(double,double)
public static double pow(double x,
double y)
x - the number to raise.y - the power to raise it to.
public static double IEEEremainder(double x,
double y)
rint() function to do this.
x - the dividend (the top half)y - the divisor (the bottom half)rint(double)public static double ceil(double x)
x - the value to act upon.x.public static double floor(double x)
x - the value to act upon.x.public static double rint(double x)
x - the value to act upon.x.public static long round(double a)
a - the argument to round.public static double toRadians(double degrees)
degrees - an angle in degreespublic static double toDegrees(double rads)
rads - an angle in radianspublic static boolean isNaN(double d)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||