org.j4me.util
Class MathFunc

java.lang.Object
  extended by org.j4me.util.MathFunc

public final class MathFunc
extends java.lang.Object

Implements the methods which are in the standard J2SE's Math class, but are not in in J2ME's.

The following methods are still missing from the implementation:

See Also:
Math

Constructor Summary
MathFunc()
           
 
Method Summary
static double acos(double a)
          Returns the arc cosine of an angle, in the range of 0.0 through Math.PI.
static double asin(double a)
          Returns the arc sine of an angle, in the range of -Math.PI/2 through Math.PI/2.
static double atan(double a)
          Returns the arc tangent of an angle, in the range of -Math.PI/2 through Math.PI/2.
static double atan2(double y, double x)
          Converts rectangular coordinates (x, y) to polar (r, theta).
static long round(double a)
          Returns the closest long to the argument.
static int round(float a)
          Returns the closest int to the argument.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MathFunc

public MathFunc()
Method Detail

acos

public static double acos(double a)
Returns the arc cosine of an angle, in the range of 0.0 through Math.PI. Special case:

Parameters:
a - - the value whose arc cosine is to be returned.
Returns:
the arc cosine of the argument.

asin

public static double asin(double a)
Returns the arc sine of an angle, in the range of -Math.PI/2 through Math.PI/2. Special cases:

Parameters:
a - - the value whose arc sine is to be returned.
Returns:
the arc sine of the argument.

atan

public static double atan(double a)
Returns the arc tangent of an angle, in the range of -Math.PI/2 through Math.PI/2. Special cases:

A result must be within 1 ulp of the correctly rounded result. Results must be semi-monotonic.

Parameters:
a - - the value whose arc tangent is to be returned.
Returns:
the arc tangent of the argument.

atan2

public static double atan2(double y,
                           double x)
Converts rectangular coordinates (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. Special cases:

A result must be within 2 ulps of the correctly rounded result. Results must be semi-monotonic.

Parameters:
y - - the ordinate coordinate
x - - the abscissa coordinate
Returns:
the theta component of the point (r, theta) in polar coordinates that corresponds to the point (x, y) in Cartesian coordinates.

round

public static int round(float a)
Returns the closest 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. In other words, the result is equal to the value of the expression:

(int)Math.floor(a + 0.5f)

Special cases:

Parameters:
a - - a floating-point value to be rounded to an integer.
Returns:
the value of the argument rounded to the nearest int value.

round

public static long round(double a)
Returns the closest long 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 long. In other words, the result is equal to the value of the expression:

(long)Math.floor(a + 0.5d)

Special cases:

Parameters:
a - - a floating-point value to be rounded to a long.
Returns:
the value of the argument rounded to the nearest long value.