Use is subject to License Terms. Your use of this web site or any of its content or software indicates your agreement to be bound by these License Terms.

Copyright © 2006 Sun Microsystems, Inc. All rights reserved.


java.lang
Class Math

java.lang.Object
  |
  +--java.lang.Math

public final class Math
extends Object

The class Math contains methods for performing basic numeric operations.

Since:
1.3

Method Summary
static int abs(int a)
          Returns the absolute value of an int value.
static long abs(long a)
          Returns the absolute value of a long value.
static int max(int a, int b)
          Returns the greater of two int values.
static long max(long a, long b)
          Returns the greater of two long values.
static int min(int a, int b)
          Returns the smaller of two int values.
static long min(long a, long b)
          Returns the smaller of two long values.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

abs

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.

Parameters:
a - an int value.
Returns:
the absolute value of the argument.
See Also:
Integer.MIN_VALUE

abs

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.

Parameters:
a - a long value.
Returns:
the absolute value of the argument.
See Also:
Long.MIN_VALUE

max

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.
Parameters:
a - an int value.
b - an int value.
Returns:
the larger of a and b.
See Also:
Long.MAX_VALUE

max

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.
Parameters:
a - a long value.
b - a long value.
Returns:
the larger of a and b.
See Also:
Long.MAX_VALUE

min

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.
Parameters:
a - an int value.
b - an int value.
Returns:
the smaller of a and b.
See Also:
Long.MIN_VALUE

min

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.
Parameters:
a - a long value.
b - a long value.
Returns:
the smaller of a and b.
See Also:
Long.MIN_VALUE


Copyright © 2006 Sun Microsystems, Inc. All rights reserved. Use is subject to License Terms. Your use of this web site or any of its content or software indicates your agreement to be bound by these License Terms.

For more information, please consult the JSR 30 specification.