Java Reference
In-Depth Information
public static double max( double n1, double n2)
public static float max( float n1, float n2)
public static long max( long n1, long n2)
public static int max( int n1, int n2)
Returns the maximum of the arguments n1 and n2 . (The method name max is overloaded to
produce four similar methods.)
EXAMPLE
Math.max(3, 2) returns 3.
public static double min( double n1, double n2)
public static float min( float n1, float n2)
public static long min( long n1, long n2)
public static int min( int n1, int n2)
Returns the minimum of the arguments n1 and n2 . (The method name min is overloaded to
produce four similar methods.)
EXAMPLE
Math.min(3, 2) returns 2 .
public static double pow( double base, double exponent)
Returns base to the power exponent .
EXAMPLE
Math.pow(2.0,3.0) returns 8.0.
public static double random()
Returns a random number greater than or equal to 0.0 and less than 1.0.
EXAMPLE
Math.random() returns 0.5505562535943004 (example value only; will return a pseudo-
random number that is less than 1 and greater than or equal to 0 the next time the statement
is executed)
public static long round( double argument)
public static int round( float argument)
Rounds its argument .
EXAMPLES
Math.round(3.2) returns 3. Math.round(3.6) returns 4.
public static double sqrt( double argument)
Returns the square root of its argument .
EXAMPLE
Math.sqrt(4) returns 2.0.
 
Search WWH ::




Custom Search