|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.rim.device.api.util.MathUtilities
public final class MathUtilities
Provides some basic numeric operations.
Method Summary | ||
---|---|---|
static double |
acos(double x)
Returns the arc cosine of the value x . |
|
static double |
asin(double x)
Returns the arc sine of the value x . |
|
static double |
atan(double x)
Returns the arc tangent of the value x . |
|
static double |
atan2(double y,
double x)
Converts rectangular coordinates (x,y) to polar coordinates (r,theta). |
|
static double |
clamp(double low,
double value,
double high)
Clamps provided double value between a lower and upper bound. |
|
static float |
clamp(float low,
float value,
float high)
Clamps provided float value between a lower and upper bound. |
|
static int |
clamp(int low,
int value,
int high)
Clamps provided integer value between a lower and upper bound. |
|
static long |
clamp(long low,
long value,
long high)
Clamps provided long integer value between a lower and upper bound. |
|
static double |
exp(double x)
Return the exponential (base e) of x. |
|
static double |
ldexp(double x,
int exp)
Returns the result of multiplying x (the significand) by 2 raised to the power of exp (the exponent). |
|
static double |
log(double x)
Return the natural logarithm (base e) of x. |
|
static int |
log2(int value)
Returns the log base 2 of the unsigned value rounded down. |
|
static int |
log2(long value)
Returns the log base 2 of the unsigned value rounded down. |
|
static double |
pow(double x,
double y)
Return x raised to the power of y . |
|
static long |
round(double a)
Returns the closest long to the argument. |
|
static int |
round(float a)
Returns the closest int to the argument. |
|
static float |
wrap(float low,
float value,
float high)
Wraps provided float value around a lower and upper bound. |
|
static int |
wrap(int low,
int value,
int high)
Wraps provided integer value around a lower and upper bound. |
|
static long |
wrap(long low,
long value,
long high)
Wraps provided long integer values around a lower and upper bound. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static int clamp(int low, int value, int high)
low
- Lower bound value; must be less than your upper bound parameter.value
- Value to clamp.high
- Upper bound value.
IllegalArgumentException
- If you provide a low parameter value
that is greater than your high parameter value.public static long clamp(long low, long value, long high)
low
- Lower bound value; must be less than your upper bound
parameter.value
- Value to clamp.high
- Upper bound value.
IllegalArgumentException
- If you provide a low parameter value
that is greater than your high parameter value.public static float clamp(float low, float value, float high)
low
- Lower bound value; must be less than your upper bound parameter.value
- Value to clamp.high
- Upper bound value.
IllegalArgumentException
- If you provide a low parameter value
that is greater than your high parameter value.public static double clamp(double low, double value, double high)
low
- Lower bound value; must be less than your upper bound parameter.value
- Value to clamp.high
- Upper bound value.
IllegalArgumentException
- If you provide a low parameter value
that is greater than your high parameter value.public static int wrap(int low, int value, int high)
This method does the opposite of MathUtilities.clamp(int,int,int)
.
low
- Lower bound value; must be less than your upper bound parameter.value
- Value to wrap.high
- Upper bound value.
IllegalArgumentException
- If you provide a low parameter value
that is greater than your high parameter value.public static long wrap(long low, long value, long high)
This method does the opposite of MathUtilities.clamp(long,long,long)
.
low
- Lower bound value; must be less than your upper bound
parameter.value
- Value to wrap.high
- Upper bound value.
IllegalArgumentException
- If you provide a low parameter value
that is greater than your high parameter value.public static float wrap(float low, float value, float high)
This method does the opposite of MathUtilities.clamp(float,float,float)
.
low
- Lower bound value; must be less than your upper bound parameter.value
- Value to wrap.high
- Upper bound value.
IllegalArgumentException
- If you provide a low parameter value
that is greater than your high parameter value.public static int log2(int value)
The value zero and one both return zero.
value
- The unsigned value to calculate log2 on.
public static int log2(long value)
The value zero and one both return a log2 result of zero.
value
- The unsigned value to calculate log2 on.
public static double log(double x)
x
- a number greater than zero.
public static double exp(double x)
x
- the power to raise e to.
public static double pow(double x, double y)
x
raised to the power of y
.
x
- the base value.y
- the exponent.
public static double asin(double x)
x
.
x
- the value.
public static double acos(double x)
x
.
x
- the value.
public static double atan(double x)
x
.
x
- the value.
public static double atan2(double y, double x)
y
- the abscissa coordinate.x
- the ordinate coordinate.
public static double ldexp(double x, int exp)
x
(the significand) by 2 raised to the power of exp
(the exponent).
x
- the significand.exp
- the exponent.
public static int round(float a)
int
to the argument. The
result is rounded to an integer by adding 1/2 if positive or
subtracting 1/2 if negative, taking the floor of the
result, and casting the result to type int
.
Special cases:
Integer.MIN_VALUE
, the result is
equal to the value of Integer.MIN_VALUE
.
Integer.MAX_VALUE
, the result is
equal to the value of Integer.MAX_VALUE
.
a
- a floating-point value to be rounded to an integer.
int
value.Integer.MAX_VALUE
,
Integer.MIN_VALUE
public static long round(double a)
long
to the argument. The result
is rounded to an integer by adding 1/2 if positive or
subtracting 1/2 if negative, taking the floor of the
result, and casting the result to type long
.
Special cases:
Long.MIN_VALUE
, the result is
equal to the value of Long.MIN_VALUE
.
Long.MAX_VALUE
, the result is
equal to the value of Long.MAX_VALUE
.
a
- a floating-point value to be rounded to a
long
.
long
value.Long.MAX_VALUE
,
Long.MIN_VALUE
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal