## net.rim.device.api.util Class MathUtilities

```java.lang.Object
|
+--net.rim.device.api.util.MathUtilities
```

public final class MathUtilities
extends Object

Provides some basic numeric operations.

 Method Summary `static int` ```clamp(int low, int value, int high)```           Clamps provided value between a lower and upper bound. `static double` `exp(double x)`           Return the exponential (base e) of x. `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 int` ```wrap(int low, int value, int high)```           Wraps provided value around a lower and upper bound.

 Methods inherited from class java.lang.Object `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

 Method Detail

### clamp

```public static int clamp(int low,
int value,
int high)```
Clamps provided value between a lower and upper bound.

Note: This method only produces sensible results if the lower bound is less than, or equal to, the higher bound.

Parameters:
`low` - Lower bound value.
`value` - Value to clamp.
`high` - Upper bound value.
Returns:
If the value is lower than the lower bound, this method returns the lower bound; if the value is higher than the higher bound, this method returns the higher bound; otherwise, this method returns the value itself.

### exp

`public static double exp(double x)`
Return the exponential (base e) of x. Interesting cases:
• If the argument is negative infinity, the result is zero.
• If the argument is positive infinity, the result is positive infinity.
• If the argument is NaN, the result is NaN.
• If the argument is greater than 7.09e+02, the result is positive infinity.
• If the argument is less than -7.45e+02, the result is zero.
Parameters:
`x` - the power to raise e to.
Returns:
e raised to the power x.
Since:
JDE 4.2.0

### log

`public static double log(double x)`
Return the natural logarithm (base e) of x. Interesting cases:
• If the argument is less than zero (including negative infinity), the result is NaN.
• If the argument is zero, the result is negative infinity.
• If the argument is positive infinity, the result is positive infinity.
• If the argument is NaN, the result is NaN.
Parameters:
`x` - a number greater than zero.
Returns:
the natural logarithm (base e) of the argument.
Since:
JDE 4.2.0

### log2

`public static int log2(int value)`
Returns the log base 2 of the unsigned value rounded down.

The value zero and one both return zero.

Parameters:
`value` - The unsigned value to calculate log2 on.
Returns:
The calculation of log2(value) (range: 0-31).
Since:
JDE 4.2.0

### log2

`public static int log2(long value)`
Returns the log base 2 of the unsigned value rounded down.

The value zero and one both return a log2 result of zero.

Parameters:
`value` - The unsigned value to calculate log2 on.
Returns:
The calculation of log2(value) (range: 0-63).
Since:
JDE 4.2.0

### wrap

```public static int wrap(int low,
int value,
int high)```
Wraps provided value around a lower and upper bound.

Note: This method only produces sensible results if the lower bound is less than, or equal to, the higher bound.

Parameters:
`low` - Lower bound value.
`value` - Value to wrap.
`high` - Upper bound value.
Returns:
If the value is lower than the lower bound, this method returns the higher bound; if the value is higher than the higher bound, this method returns the lower bound; otherwise, this method returns the value itself. This is the opposite of clamp()
Since:
JDE 4.0.0