|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--moka.lang.Object | +--moka.lang.Math
The class Math
contains methods for performing basic
numeric operations such as the elementary exponential, logarithm,
square root, and trigonometric functions.
Field Summary | |
static double |
E
The double value that is closer than any other to
e, the base of the natural logarithms. |
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. |
Constructor Summary | |
Math()
|
Method Summary | |
static byte |
abs(byte a)
Returns the absolute value of a byte value. |
static double |
abs(double a)
Returns the absolute value of an int value. |
static int |
abs(int a)
Returns the absolute value of an int value. |
static long |
abs(long a)
Returns the absolute value of a long value. |
static short |
abs(short a)
Returns the absolute value of a short value. |
static double |
acos(double a)
Returns the arc cosine of an angle. |
static double |
asin(double a)
Returns the arc sine of an angle. |
static double |
atan(double a)
Returns the arc tangent of an angle. |
static double |
atan2(double y,
double x)
Converts rectangular coordinates ( x , y )
to polar (r, theta). |
static double |
ceil(double a)
Returns the smallest (closest to negative infinity) double value that is not less than the argument and is
equal to a mathematical integer. |
static double |
cos(double a)
Returns the trigonometric cosine of an angle. |
static double |
exp(double a)
Returns Euler's number e raised to the power of a double value. |
static double |
floor(double a)
Returns the largest (closest to positive infinity) double value that is not greater than the argument and
is equal to a mathematical integer. |
static double |
log(double a)
Returns the natural logarithm (base e) of a double
value. |
static byte |
max(byte a,
byte b)
Returns the greater of two byte values. |
static double |
max(double a,
double b)
Returns the greater of two double values. |
static int |
max(int a,
int b)
Returns the greater of two int values. |
static long |
max(long a,
long b)
Returns the greater of two long values. |
static short |
max(short a,
short b)
Returns the greater of two short values. |
static byte |
min(byte a,
byte b)
Returns the smaller of two byte values. |
static double |
min(double a,
double b)
Returns the smaller of two double values. |
static int |
min(int a,
int b)
Returns the smaller of two int values. |
static long |
min(long a,
long b)
Returns the smaller of two long values. |
static short |
min(short a,
short b)
Returns the smaller of two short values. |
static double |
pow(double a,
double b)
Returns of value of the first argument raised to the power of the second argument. |
static short |
rand()
Returns a short value with a positive sign, greater
than or equal to 0 and less than 32767 . |
static short |
rand(short num)
Returns a short value with a positive sign, greater
than or equal to 0 and less than the specified number. |
static double |
random()
Returns a double value with a positive sign, greater
than or equal to 0.0 and less than 1.0 . |
static void |
randomize()
Initializes the random number generator with a random value (picked from the timer). |
static int |
round(double a)
Returns the closest int to the argument. |
static double |
sin(double a)
Returns the trigonometric sine of an angle. |
static double |
sqrt(double a)
Returns the correctly rounded positive square root of a double value. |
static double |
tan(double a)
Returns the trigonometric tangent of an angle. |
static double |
toDegrees(double angrad)
Converts an angle measured in radians to an approximately equivalent angle measured in degrees. |
static double |
toRadians(double angdeg)
Converts an angle measured in degrees to an approximately equivalent angle measured in radians. |
Methods inherited from class moka.lang.Object |
equals, finalize, getClassName, toString |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final double E
double
value that is closer than any other to
e, the base of the natural logarithms.
public static final double PI
double
value that is closer than any other to
pi, the ratio of the circumference of a circle to its
diameter.
Constructor Detail |
public Math()
Method Detail |
public static byte abs(byte a)
byte
value.
If the argument is not negative, the argument is returned.
If the argument is negative, the negation of the argument is returned.
a
- the argument whose absolute value is to be determined
public static short abs(short a)
short
value.
If the argument is not negative, the argument is returned.
If the argument is negative, the negation of the argument is returned.
a
- the argument whose absolute value is to be determined
public static int abs(int a)
int
value.
If the argument is not negative, the argument is returned.
If the argument is negative, the negation of the argument is returned.
a
- the argument whose absolute value is to be determined
public static long abs(long a)
long
value.
If the argument is not negative, the argument is returned.
If the argument is negative, the negation of the argument is returned.
a
- the argument whose absolute value is to be determined
public static double abs(double a)
int
value.
If the argument is not negative, the argument is returned.
If the argument is negative, the negation of the argument is returned.
a
- the argument whose absolute value is to be determined
public static double acos(double a)
a
- the value whose arc cosine is to be returned.
public static double asin(double a)
a
- the value whose arc sine is to be returned.
public static double atan(double a)
a
- the value whose arc tangent is to be returned.
public static double atan2(double y, double x)
x
, y
)
to polar (r, theta).
This method computes the phase theta by computing an arc tangent
of y/x
in the range of -pi to pi.
y
- the ordinate coordinatex
- the abscissa coordinate
public static double ceil(double a)
double
value that is not less than the argument and is
equal to a mathematical integer.
a
- a value.
public static double cos(double a)
a
- an angle, in radians.
public static double exp(double a)
double
value.
a
- the exponent to raise e to.
a
,
where e is the base of the natural logarithms.public static double floor(double a)
double
value that is not greater than the argument and
is equal to a mathematical integer.
a
- a value
public static double log(double a)
double
value.
a
- a number greater than 0.0
.
a
, the natural logarithm of
a
.public static byte max(byte a, byte b)
byte
values. That is, the
result is the argument closer to the value of
Byte.MAX_VALUE
. If the arguments have the same value,
the result is that same value.
a
- an argument.b
- another argument.
a
and b
.public static short max(short a, short b)
short
values. That is, the
result is the argument closer to the value of
Short.MAX_VALUE
. If the arguments have the same value,
the result is that same value.
a
- an argument.b
- another argument.
a
and b
.public static int max(int a, int b)
int
values. That is, the
result is the argument closer to the value of
Integer.MAX_VALUE
. If the arguments have the same value,
the result is that same value.
a
- an argument.b
- another argument.
a
and b
.public static long max(long a, long b)
long
values. That is, the
result is the argument closer to the value of
Long.MAX_VALUE
. If the arguments have the same value,
the result is that same value.
a
- an argument.b
- another argument.
a
and b
.public static double max(double a, double b)
double
values. That is, the
result is the argument closer to the value of
Double.MAX_VALUE
. If the arguments have the same value,
the result is that same value.
a
- an argument.b
- another argument.
a
and b
.public static byte min(byte a, byte b)
byte
values. That is,
the result the argument closer to the value of
Byte.MIN_VALUE
. If the arguments have the same
value, the result is that same value.
a
- an argument.b
- another argument.
a
and b
.public static short min(short a, short b)
short
values. That is,
the result the argument closer to the value of
Short.MIN_VALUE
. If the arguments have the same
value, the result is that same value.
a
- an argument.b
- another argument.
a
and b
.public static int min(int a, int b)
int
values. That is,
the result the argument closer to the value of
Integer.MIN_VALUE
. If the arguments have the same
value, the result is that same value.
a
- an argument.b
- another argument.
a
and b
.public static long min(long a, long b)
long
values. That is,
the result the argument closer to the value of
Long.MIN_VALUE
. If the arguments have the same
value, the result is that same value.
a
- an argument.b
- another argument.
a
and b
.public static double min(double a, double b)
double
values. That is,
the result the argument closer to the value of
Double.MIN_VALUE
. If the arguments have the same
value, the result is that same value.
a
- an argument.b
- another argument.
a
and b
.public static double pow(double a, double b)
a
- the base.b
- the exponent.
ab
.public static void randomize()
public static double random()
double
value with a positive sign, greater
than or equal to 0.0
and less than 1.0
.
Returned values are chosen pseudorandomly with (approximately)
uniform distribution from that range.
double
greater than or equal
to 0.0
and less than 1.0
.public static short rand()
short
value with a positive sign, greater
than or equal to 0
and less than 32767
.
Returned values are chosen pseudorandomly with (approximately)
uniform distribution from that range.
short
greater than or equal
to 0
and less than 32767
.public static short rand(short num)
short
value with a positive sign, greater
than or equal to 0
and less than the specified number.
Returned values are chosen pseudorandomly with (approximately)
uniform distribution from that range.
num
- the number to be specified
short
greater than or equal
to 0
and less than the specified number.public static int round(double a)
int
to the argument. The result
is rounded to an integer by adding 1/2, taking the floor of the
result, and casting the result to type int
.
a
- a floating-point value to be rounded to a
int
.
int
value.public static double sin(double a)
a
- an angle, in radians.
public static double sqrt(double a)
double
value.
a
- a value.
a
.public static double tan(double a)
a
- an angle, in radians.
public static double toRadians(double angdeg)
angdeg
- an angle, in degrees
angdeg
in radians.public static double toDegrees(double angrad)
cos(toRadians(90.0))
to exactly
equal 0.0
.
angrad
- an angle, in radians
angrad
in degrees.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |