java.lang.Object
↳ java.lang.Math
类常用的常量和方法:
Math.E记录e的常量
Math.PI 记录的圆周率
Math.IEEEremainder 求余
Math.abs 求绝对值
Math.acos 反余弦函数
Math.asin 反正弦函数
Math.atan 反正切函
Math.atan2 商的反正切函数
Math.sin 正弦函数
Math.cos 余弦函数
Math.tan 正切函数数
Math.cbrt
Math.ceil 得到不小于某数的最大整数
Math.cosh 返回最近的双参数的双曲余弦近似。
Math.exp 求e的任意次方
static double expm1(double d) 返回最接近e d - 1的任意次方近似。
Math.floor 得到不大于某数的最大整数
例如:Math.floor(12.7) =12.0
Math.ceil(12.7) =13.0
ceil()是天花板,即向上取整。floor是地板,向下取整。round是四舍五入。
Math.hypot(double x, double y) 返回x2 + y2)的平方根
Math.log 自然对数
Math.max 求两数中最大
Math.min 求两数中最小
Math.pow 求某数的任意次方, 抛出ArithmeticException处理溢出异常
Math.random 返回0.0,1.0之间的一个随机数
Math.rint 求距离某数最近的整数(可能比某数大,也可能比它小)
Math.round 同上,返回int型或者long型(上一个函数返回do