package com.wyq.StringBuffer;
public class TestMath {
public static void main(String[] args) {
/**
* math.abs是取绝对值的方法
*/
System.out.println(Math.abs(20) + "\t" + Math.abs(-10.0123) + "\t" + Math.abs(0));
/**
* ceil()是指天花板,向上取整
*/
System.out.println(Math.ceil(-3.900001));
System.out.println(Math.ceil(3.000001));
/**
* floor()是指向下取整
*/
System.out.println("floor的测试:" + Math.floor(3.99999));
System.out.println("floor的测试:" + Math.floor(-3.99999));
/**
* 四舍五入round()
*/
System.out.println(Math.round(3.49999));
System.out.println(Math.round(3.5000001));
/**
* 取随机数
*/
System.out.println("random()的测试:" + Math.random());
/**
* 开平方
*/
System.out.println("sqrt()的测试" + Math.sqrt(9));
/**
* 三次方
*/
System.out.println("pow():" + Math.pow(3, 4));
System.out.println(Math.E);
System.out.println(Math.PI);
}
}
05-04
130
08-09
08-09
08-09
08-09