Mathpublic final class Math extends Object The class Math contains methods for performing basic
numeric operations. |
Constructors Summary |
---|
private Math()Don't let anyone instantiate this class.
|
Methods Summary |
---|
public static int | abs(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.
return (a < 0) ? -a : a;
| public static long | abs(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.
return (a < 0) ? -a : a;
| public static int | max(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.
return (a >= b) ? a : b;
| public static long | max(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.
return (a >= b) ? a : b;
| public static int | min(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.
return (a <= b) ? a : b;
| public static long | min(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.
return (a <= b) ? a : b;
|
|