//abs取绝对值:abs(a)
System.out.println("绝对值"+Math.abs(3.2));
//sqrt开平方根:sqrt(a)
System.out.println("开平方根"+Math.sqrt(4));
System.out.println("开平方根"+Math.sqrt(5));
//求幂:pow(double a, double b) a的b次幂
System.out.println("求幂"+Math.pow(3,5));
//向下取整: floor(double a)
System.out.println("向下取整"+Math.floor(3.2));
//向上取整: ceil(double a)
System.out.println("向上取整"+Math.ceil(3.8));
//四舍五入:long round(double a)
System.out.println("四舍五入"+Math.round(5.6));
//随机数:random() 返回0.0到1.0的随机数
System.out.println("随机数"+Math.random());
输出:
绝对值3.2
开平方根2.0
开平方根2.23606797749979
求幂243.0
向下取整3.0
向上取整4.0
四舍五入6
随机数0.06399304352536916