天天看點

歡迎使用CSDN-markdown編輯器Math

此文章隻是對math進行大概的介紹,示例後續再上,java.math.math類常用的常量和方法:

math.pi 記錄的圓周率

math.e記錄e的常量

math.abs 求絕對值

math.sin 正弦函數 math.asin 反正弦函數

math.cos 餘弦函數 math.acos 反餘弦函數

math.tan 正切函數 math.atan 反正切函數 math.atan2 商的反正切函數

math.todegrees 弧度轉化為角度 math.toradians 角度轉化為弧度

math.ceil 得到不小于某數的最大整數

math.floor 得到不大于某數的最大整數

ceil()是天花闆,即向上取整。floor是地闆,向下取整。round是四舍五入。

math.ieeeremainder 求餘

math.max 求兩數中最大

math.min 求兩數中最小

math.sqrt 求開方

math.pow 求某數的任意次方, 抛出arithmeticexception處理溢出異常

math.sqrt(x):平方根

math.pow(x,y):x的y次方

math.exp 求e的任意次方

math.log10 以10為底的對數

math.log 自然對數

math.rint 求距離某數最近的整數(可能比某數大,也可能比它小)

math.round 同上,傳回int型或者long型(上一個函數傳回double型)

math.random 傳回0,1之間的一個随機數