数学计算工具类Math

常用静态方法:

1、public static double abs(double num):获取绝对值

使用方法:double num = Math.abs(-11.2); // 11.2


1、public static double ceil(double num):向上取整

使用方法:double num = Math.ceil(11.2); // 12


1、public static double floor(double num):向下取整

使用方法:double num = Math.floor(11.2); // 11


1、public static long round(double num):四舍五入

使用方法:long num = Math.round(11.2); // 11

long num = Math.round(11.2); // 11

long num = Math.round(11.5); // 12


另:Math.PI为double类型常量,可直接使用。

猜你喜欢

转载自www.cnblogs.com/changwe12/p/12651131.html