两数相较取其大:
Math.max(某1,某2)
比较大的值===》例: Math.max(2,3) ------》3
两数相较取其小:
Math.min(某1,某2)
比较小的值===》例: Math.max(2,3) ------》2
绝对值:
Math.abs(某)
绝对值===》例:Math.abs(-2) ------》2
a的b次方:
Math.pow(a,b)
平方根===》例:Math.pow(2,3) ------》8 这个值大多为double
平方根:
Math.sqrt(某)
平方根===》例:Math.sqrt(16) ------》4
立方根:
Math.cbrt(某)
立方根===》例:Math.cbrt(8) ------》2
向下取整:
Math.floor(某)
向下取整===》例:Math.floor(8.1) ------》8
Math.floor(某)
向下取整===》例:Math.floor(-8.1) ------》-9
向上取整:
Math.ceil(某)
向下取整===》例:Math.ceil(8.1) ------》9
Math.ceil(某)
向下取整===》例:Math.ceil(-8.1) ------》-8
四舍五入:
Math.round(某)
四舍五入===》例:Math.round(8.1) ------》8
Math.round(某)
四舍五入===》例:Math.round(-8.1) ------》-8
注意:
float —返回值–> int
double —返回值–> long