Math数学工具类、向上取整,向下取整,四舍五入,最大值
package com.guoba.math; public class MathTest { /* Math数学工具类,包含以下方法: .ceil() 向上取整 .floor() 向下取整 .round() 四舍五入 .max() 最大值 .min() 最小值 .abs() 绝对值 */ public static void main(String[] args) { Math.max(1,2);//2 Math.min(1,2);//1 Math.abs(-4);//4 Math.ceil(4.36);//5 Math.floor(4.36);//4 Math.round(4.5);//5 Math.round(4.4);//4 System.out.println(Math.max(1,2)); System.out.println(Math.min(1,2)); System.out.println(Math.abs(-4)); System.out.println(Math.ceil(4.36)); System.out.println( Math.floor(4.36)); System.out.println(Math.round(4.4)); } }