public class MathPlus
extends java.lang.Object
Math
, but
with overloaded methods that return floats when passed float arguments.
(This eliminates ugly casts when using floats.) This class also defines
useful additional constants, such as FLT_PI
.Math
Modifier and Type | Field and Description |
---|---|
static double |
DBL_E
The double value that is closer than any other to e,
the base of the natural logarithm.
|
static double |
DBL_EPSILON
The smallest double value e such that (1+e) does not equal 1.
|
static double |
DBL_MAX
The maximum positive double value.
|
static double |
DBL_MIN
The minimum positive double value.
|
static double |
DBL_PI
The double value that is closer than any other to pi,
the ratio of the circumference of a circle to its diameter.
|
static double |
E
The double value that is closer than any other to e,
the base of the natural logarithm.
|
static float |
FLT_E
The float value that is closer than any other to e,
the base of the natural logarithm.
|
static float |
FLT_EPSILON
The smallest float value e such that (1+e) does not equal 1.
|
static float |
FLT_MAX
The maximum positive float value.
|
static float |
FLT_MIN
The minimum positive float value.
|
static float |
FLT_PI
The float value that is closer than any other to pi,
the ratio of the circumference of a circle to its diameter.
|
static double |
PI
The double value that is closer than any other to pi,
the ratio of the circumference of a circle to its diameter.
|
Modifier and Type | Method and Description |
---|---|
static double |
abs(double x)
Returns the absolute value of the specified value.
|
static float |
abs(float x)
Returns the absolute value of the specified value.
|
static int |
abs(int x)
Returns the absolute value of the specified value.
|
static long |
abs(long x)
Returns the absolute value of the specified value.
|
static double |
acos(double x)
Returns the arc cosine of the specified value, in the range
0.0 through pi.
|
static float |
acos(float x)
Returns the arc cosine of the specified value, in the range
0.0 through pi.
|
static double |
asin(double x)
Returns the arc sine of the specified value, in the range
-pi/2 through pi/2.
|
static float |
asin(float x)
Returns the arc sine of the specified value, in the range
-pi/2 through pi/2.
|
static double |
atan(double x)
Returns the arc tangent of the specified value, in the range
-pi/2 through pi/2.
|
static float |
atan(float x)
Returns the arc tangent of the specified value, in the range
-pi/2 through pi/2.
|
static double |
atan2(double y,
double x)
Computes the arc tangent of the specified y/x, in the range
-pi to pi.
|
static float |
atan2(float y,
float x)
Computes the arc tangent of the specified y/x, in the range
-pi to pi.
|
static double |
ceil(double x)
Returns the smallest (closest to negative infinity) value that is greater
than or equal to the argument and is equal to a mathematical integer.
|
static float |
ceil(float x)
Returns the smallest (closest to negative infinity) value that is greater
than or equal to the argument and is equal to a mathematical integer.
|
static double |
cos(double x)
Returns the trigonometric cosine of an angle.
|
static float |
cos(float x)
Returns the trigonometric cosine of an angle.
|
static double |
cosh(double x)
Returns the hyperbolic cosine of the specified value.
|
static float |
cosh(float x)
Returns the hyperbolic cosine of the specified value.
|
static double |
exp(double x)
Returns the value of e raised to the specified power.
|
static float |
exp(float x)
Returns the value of e raised to the specified power.
|
static double |
floor(double x)
Returns the largest (closest to positive infinity) value that is less
than or equal to the argument and is equal to a mathematical integer.
|
static float |
floor(float x)
Returns the largest (closest to positive infinity) value that is less
than or equal to the argument and is equal to a mathematical integer.
|
static double |
log(double x)
Returns the natural logarithm (base e) of the specified value.
|
static float |
log(float x)
Returns the natural logarithm (base e) of the specified value.
|
static double |
log10(double x)
Returns the logarithm base 10 of the specified value.
|
static float |
log10(float x)
Returns the logarithm base 10 of the specified value.
|
static double |
max(double a,
double b)
Returns the maximum of the specified values.
|
static double |
max(double a,
double b,
double c)
Returns the maximum of the specified values.
|
static double |
max(double a,
double b,
double c,
double d)
Returns the maximum of the specified values.
|
static float |
max(float a,
float b)
Returns the maximum of the specified values.
|
static float |
max(float a,
float b,
float c)
Returns the maximum of the specified values.
|
static float |
max(float a,
float b,
float c,
float d)
Returns the maximum of the specified values.
|
static int |
max(int a,
int b)
Returns the maximum of the specified values.
|
static int |
max(int a,
int b,
int c)
Returns the maximum of the specified values.
|
static int |
max(int a,
int b,
int c,
int d)
Returns the maximum of the specified values.
|
static long |
max(long a,
long b)
Returns the maximum of the specified values.
|
static long |
max(long a,
long b,
long c)
Returns the maximum of the specified values.
|
static long |
max(long a,
long b,
long c,
long d)
Returns the maximum of the specified values.
|
static double |
min(double a,
double b)
Returns the minimum of the specified values.
|
static double |
min(double a,
double b,
double c)
Returns the minimum of the specified values.
|
static double |
min(double a,
double b,
double c,
double d)
Returns the minimum of the specified values.
|
static float |
min(float a,
float b)
Returns the minimum of the specified values.
|
static float |
min(float a,
float b,
float c)
Returns the minimum of the specified values.
|
static float |
min(float a,
float b,
float c,
float d)
Returns the minimum of the specified values.
|
static int |
min(int a,
int b)
Returns the minimum of the specified values.
|
static int |
min(int a,
int b,
int c)
Returns the minimum of the specified values.
|
static int |
min(int a,
int b,
int c,
int d)
Returns the minimum of the specified values.
|
static long |
min(long a,
long b)
Returns the minimum of the specified values.
|
static long |
min(long a,
long b,
long c)
Returns the minimum of the specified values.
|
static long |
min(long a,
long b,
long c,
long d)
Returns the minimum of the specified values.
|
static double |
pow(double x,
double y)
Returns the value of x raised to the y'th power.
|
static float |
pow(float x,
float y)
Returns the value of x raised to the y'th power.
|
static double |
rint(double x)
Returns the value that is closest to the specified value and is equal
to a mathematical integer.
|
static float |
rint(float x)
Returns the value that is closest to the specified value and is equal
to a mathematical integer.
|
static long |
round(double x)
Returns the closest long to the specified value.
|
static int |
round(float x)
Returns the closest int to the specified value.
|
static double |
signum(double x)
Returns the signum of the specified value.
|
static float |
signum(float x)
Returns the signum of the specified value.
|
static double |
sin(double x)
Returns the trigonometric sine of an angle.
|
static float |
sin(float x)
Returns the trigonometric sine of an angle.
|
static double |
sinh(double x)
Returns the hyperbolic sine of the specified value.
|
static float |
sinh(float x)
Returns the hyperbolic sine of the specified value.
|
static double |
sqrt(double x)
Returns the positive square root of a the specified value.
|
static float |
sqrt(float x)
Returns the positive square root of a the specified value.
|
static double |
tan(double x)
Returns the trigonometric tangent of an angle.
|
static float |
tan(float x)
Returns the trigonometric tangent of an angle.
|
static double |
tanh(double x)
Returns the hyperbolic tangent of the specified value.
|
static float |
tanh(float x)
Returns the hyperbolic tangent of the specified value.
|
static double |
toDegrees(double angrad)
Converts an angle measured in radians to degrees.
|
static float |
toDegrees(float angrad)
Converts an angle measured in radians to degrees.
|
static double |
toRadians(double angdeg)
Converts an angle measured in degrees to radians.
|
static float |
toRadians(float angdeg)
Converts an angle measured in degrees to radians.
|
public static final double E
public static final float FLT_E
public static final double DBL_E
public static final double PI
public static final float FLT_PI
public static final double DBL_PI
public static final float FLT_MAX
public static final float FLT_MIN
public static final float FLT_EPSILON
public static final double DBL_MAX
public static final double DBL_MIN
public static final double DBL_EPSILON
public static float sin(float x)
x
- the angle, in radians.public static double sin(double x)
x
- the angle, in radians.public static float cos(float x)
x
- the angle, in radians.public static double cos(double x)
x
- the angle, in radians.public static float tan(float x)
x
- the angle, in radians.public static double tan(double x)
x
- the angle, in radians.public static float asin(float x)
x
- the value.public static double asin(double x)
x
- the value.public static float acos(float x)
x
- the value.public static double acos(double x)
x
- the value.public static float atan(float x)
x
- the value.public static double atan(double x)
x
- the value.public static float atan2(float y, float x)
y
- the ordinate coordinate y.x
- the abscissa coordinate x.public static double atan2(double y, double x)
y
- the ordinate coordinate y.x
- the abscissa coordinate x.public static float toRadians(float angdeg)
angdeg
- an angle, in degrees.public static double toRadians(double angdeg)
angdeg
- an angle, in degrees.public static float toDegrees(float angrad)
angrad
- an angle, in radians.public static double toDegrees(double angrad)
angrad
- an angle, in radians.public static float exp(float x)
x
- the exponent.public static double exp(double x)
x
- the exponent.public static float log(float x)
x
- the value.public static double log(double x)
x
- the value.public static float log10(float x)
x
- the value.public static double log10(double x)
x
- the value.public static float sqrt(float x)
x
- the value.public static double sqrt(double x)
x
- the value.public static float pow(float x, float y)
x
- the base.y
- the exponent.public static double pow(double x, double y)
x
- the base.y
- the exponent.public static float sinh(float x)
x
- the value.public static double sinh(double x)
x
- the value.public static float cosh(float x)
x
- the value.public static double cosh(double x)
x
- the value.public static float tanh(float x)
x
- the value.public static double tanh(double x)
x
- the value.public static float ceil(float x)
x
- a value.public static double ceil(double x)
x
- a value.public static float floor(float x)
x
- a value.public static double floor(double x)
x
- a value.public static float rint(float x)
x
- the value.public static double rint(double x)
x
- the value.public static int round(float x)
(int)Math.floor(a+0.5f)
.x
- the value.public static long round(double x)
(long)Math.floor(a+0.5)
.x
- the value.public static float signum(float x)
x
- the value.public static double signum(double x)
x
- the value.public static int abs(int x)
x
- the value.public static long abs(long x)
x
- the value.public static float abs(float x)
Math.abs
.x
- the value.public static double abs(double x)
Math.abs
.x
- the value.public static int max(int a, int b)
a
- a value.b
- a value.public static int max(int a, int b, int c)
a
- a value.b
- a value.c
- a value.public static int max(int a, int b, int c, int d)
a
- a value.b
- a value.c
- a value.d
- a value.public static long max(long a, long b)
a
- a value.b
- a value.public static long max(long a, long b, long c)
a
- a value.b
- a value.c
- a value.public static long max(long a, long b, long c, long d)
a
- a value.b
- a value.c
- a value.d
- a value.public static float max(float a, float b)
a
- a value.b
- a value.public static float max(float a, float b, float c)
a
- a value.b
- a value.c
- a value.public static float max(float a, float b, float c, float d)
a
- a value.b
- a value.c
- a value.d
- a value.public static double max(double a, double b)
a
- a value.b
- a value.public static double max(double a, double b, double c)
a
- a value.b
- a value.c
- a value.public static double max(double a, double b, double c, double d)
a
- a value.b
- a value.c
- a value.d
- a value.public static int min(int a, int b)
a
- a value.b
- a value.public static int min(int a, int b, int c)
a
- a value.b
- a value.c
- a value.public static int min(int a, int b, int c, int d)
a
- a value.b
- a value.c
- a value.d
- a value.public static long min(long a, long b)
a
- a value.b
- a value.public static long min(long a, long b, long c)
a
- a value.b
- a value.c
- a value.public static long min(long a, long b, long c, long d)
a
- a value.b
- a value.c
- a value.d
- a value.public static float min(float a, float b)
a
- a value.b
- a value.public static float min(float a, float b, float c)
a
- a value.b
- a value.c
- a value.public static float min(float a, float b, float c, float d)
a
- a value.b
- a value.c
- a value.d
- a value.public static double min(double a, double b)
a
- a value.b
- a value.public static double min(double a, double b, double c)
a
- a value.b
- a value.c
- a value.public static double min(double a, double b, double c, double d)
a
- a value.b
- a value.c
- a value.d
- a value.