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
网友评论