Math 物件
以下之 4type 表示 {int, float, double, long}。
完整屬性及方法
| 回傳值/對象 | 函式 (數據型態 參數) | 說明 |
|---|---|---|
| 4type | abs(4type i) | 取 i 的絕對值 |
| 4type | max(4type i, 4type j) | 回傳 i、j 的較大值 |
| 4type | min(4type i, 4type j) | 回傳 i、j 的較小值 |
| double | pow(double i, double j) | 回傳 i 的 j 次方 |
| long、int | round(4type i) | 將 i 四捨五入後回傳 |
| double | random() | 回傳介於 0 與 1 之間的隨機數 |
| double | sqrt(double i) | 回傳 i 的平方根 |
| double | ceil(double i) | 回傳大於或等於 i 的最小整數 |
| double | sin(double i) | 回傳 i 的正弦函數值 |
| double | cos(double i) | 回傳 i 的餘弦函數值 |
| double | tan(double i) | 回傳 i 的正切函數值 |
| double | atan(double i) | 回傳 i 的反正切函數值 |
| double | acos(double i) | 回傳 i 的反餘弦函數值 |
| double | asin(double i) | 回傳 i 的反正弦函數值 |
注意: 沒有 Math.floor(i)?ceil(i) 回傳類型為 double。
