持续记录
临时数据
String tempData = "5.20"
向上取整(Math.ceil())
Math.ceil(Double.parseDouble(tempData))
输出值:6.0
向下取整(Math.floor())
Math.floor(Double.parseDouble(tempData))
输出值:5.0
四舍五入(Math.round())
long round = Math.round(tempData);
输出值:5.0
绝对值获取(Math.abs())
主要作用 :负数变正数
public static void main(String args[]) {
//这里是负数
System.out.println (Math.abs (-6.6));
System.out.println (Math.abs (4.8));
}
输出值:
6.6
4.8