FileDocCategorySizeDatePackage
Math.javaAPI DocphoneME MR2 API (J2ME)4888Wed May 02 17:59:54 BST 2007java.lang

# Math

public final class Math extends Object
 The class `Math` contains methods for performing basic numeric operations.
 version1.48, 12/04/99 (CLDC 1.0, Spring 2000)since1.3

Fields Summary
Constructors Summary
private Math()
Don't let anyone instantiate this class.

Methods Summary
public static intabs(int a)
Returns the absolute value of an `int` value. If the argument is not negative, the argument is returned. If the argument is negative, the negation of the argument is returned.

Note that if the argument is equal to the value of `Integer.MIN_VALUE`, the most negative representable `int` value, the result is that same value, which is negative.

 parama an `int` value.returnthe absolute value of the argument.seejava.lang.Integer#MIN_VALUE

``````        return (a < 0) ? -a : a;
``````
public static longabs(long a)
Returns the absolute value of 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.

Note that if the argument is equal to the value of `Long.MIN_VALUE`, the most negative representable `long` value, the result is that same value, which is negative.

 parama a `long` value.returnthe absolute value of the argument.seejava.lang.Long#MIN_VALUE

``````        return (a < 0) ? -a : a;
``````
public static intmax(int a, int b)
Returns the greater of two `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.

 parama an `int` value.paramb an `int` value.returnthe larger of `a` and `b`.seejava.lang.Long#MAX_VALUE

``````        return (a >= b) ? a : b;
``````
public static longmax(long a, long b)
Returns the greater of two `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.

 parama a `long` value.paramb a `long` value.returnthe larger of `a` and `b`.seejava.lang.Long#MAX_VALUE

``````        return (a >= b) ? a : b;
``````
public static intmin(int a, int b)
Returns the smaller of two `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.

 parama an `int` value.paramb an `int` value.returnthe smaller of `a` and `b`.seejava.lang.Long#MIN_VALUE

``````        return (a <= b) ? a : b;
``````
public static longmin(long a, long b)
Returns the smaller of two `long` values. That is, the result is the argument closer to the value of `Long.MIN_VALUE`. If the arguments have the same value, the result is that same value.

 parama a `long` value.paramb a `long` value.returnthe smaller of `a` and `b`.seejava.lang.Long#MIN_VALUE

``````        return (a <= b) ? a : b;
``````