Math工具类
2020-02-03 本文已影响0人
起名字真难难难
1、获取绝对值
public static double abs(double num);
double min=-10.8;
System.out.println(Math.abs(min));
2、
public static double ceil(double num);
double min=-10.8;
System.out.println(Math.ceil(min));
image.png
3、向下取整
public static double floor(double num);
4、四舍五入
public static long round(double)
5、圆周率
Math.PI
注:
(1)给明一个范围要用for循环
double max=5.9;
int count=0;
for(int i = (int) Math.ceil(min); i<max; i++){
}
(2)复习:强制转换
int i = (int) min