/*API的使用,用Math类做练习;
注意:java中java.lang下面的所有类都不需要引入,可以直接来使用.
1:自然对数:Math.E;
2:圆周率:Math.PI;
3:绝对值:Math.abs(-1.5);
4:把小数去掉整数加1:Math.ceil(12.1);
5:把小数位舍弃:Math.floor(12.9);
6:比较两个数的大小:Math.max(12.9,27);
7:计算某个是的n次幂:Math.pow(3,3);
8:四舍五入:Math.round(4.5);
9:开平方:Math.sqrt(16);
*/
public class Han{
public static void main(String[] args){
System.out.println(Math.E);
System.out.println(Math.PI);
double a = Math.abs(-1.5);
System.out.println("绝对值:"+a);
double b = Math.ceil(12.1);
System.out.println("把小数去掉整数加1:"+b);
double c = Math.floor(12.9);
System.out.println("把小数位舍弃:"+c);
double d = Math.max(12.9,27);
System.out.println("比较两个数的大小:"+d);
double e = Math.pow(3,3);
System.out.println("计算某个数的n次幂:"+e);
double f = Math.round(4.5);
System.out.println("四舍五入:"+f);
double g = Math.sqrt(16);
System.out.println("开平方:"+g);
}
}