java.lang.Math
@Test public void Test1() { //三角函数和角度问题 System.out.println("sin(π/2):"+Math.sin(Math.PI / 2)); System.out.println("sin(90°):"+Math.signum(90)); System.out.println("弧度转角度:"+Math.toDegrees(Math.PI / 2)); System.out.println("角度转弧度:"+Math.toRadians(90)); //科学计算 System.out.println("4开方:"+Math.sqrt(4)); System.out.println("-10.312的绝对值:"+Math.abs(-10.312)); System.out.println("2的8次方:"+Math.pow(2,8)); //四舍五入 System.out.println("3.1四舍五入:"+Math.round(3.1)); System.out.println("3.1向上取整:"+Math.ceil(3.1)); System.out.println("3.1向下取整:"+Math.floor(3.1)); //最大最小值 System.out.println("1,2中的最大值:"+Math.max(1,2)); System.out.println("1,2中的最小值:"+Math.min(1,2)); //随机数 System.out.println("产生随机数(0~1):"+Math.random()); //对数运算 System.out.println("lg(10):"+Math.log(10)); System.out.println("lg(10):"+Math.log10(10)); }
sin(π/2):1.0 sin(90°):1.0 弧度转角度:90.0 角度转弧度:1.5707963267948966 4开方::2.0 -10.312的绝对值:10.312 2的8次方:256.0 3.1四舍五入:3 3.1向上取整:4.0 3.1向下取整:3.0 1,2中的最大值:2 1,2中的最小值:1 产生随机数(0~1):0.034497497944476874 lg(10):2.302585092994046 lg(10):1.0