(1)min()
返回两个参数中的最小值。
double min(double arg1, double arg2);
float min(float arg1, float arg2);
int min(int arg1, int arg2);
long min(long arg1, long arg2);
System.out.println(Math.min(12.123, 12.456));
System.out.println(Math.min(23.12, 23.0));
(2)max()
返回两个参数中的最大值。
double max(double arg1, double arg2);
float max(float arg1, float arg2);
int max(int arg1, int arg2);
long max(long arg1, long arg2);
System.out.println(Math.max(12.123, 18.456));
System.out.println(Math.max(23.12, 23.0));
(3)pow()
pow() 方法用于返回第一个参数的第二个参数次方。
double pow(double base, double exponent);
System.out.printf("pow(%.3f, %.3f) 为 %.3f%n", x, y, Math.pow(x, y));
(4)sqrt()
sqrt() 方法用于返回参数的算术平方根
double sqrt(double d);
System.out.printf("sqrt(%.3f) 为 %.3f%n", x, Math.sqrt(x));
(5)random()
random() 方法用于返回一个随机数,随机数范围为 0.0 =< Math.random < 1.0。
static double random();
System.out.println( Math.random() );