double E | 自然対数の底 e にもっとも近い double 値です。 |
double PI | 円周とその直径の比 pi にもっとも近い double 値です。 |
double(*1) abs(double(*1) a) | double 値の絶対値を返します。 |
double ceil(double a) | 引数の値以上で、計算上の整数と等しい、最小の (負の無限大にもっとも近い) double 値を返します。 |
double cos(double a) | 指定された角度の余弦 (コサイン) を返します。 |
double exp(double a) | オイラー数 e を double 値で累乗した値を返します。 |
double floor(double a) | 引数の値以下で、計算上の整数と等しい、最大の (無限大にもっとも近い) double 値を返します。 |
double log(double a) | 指定された double 値の自然対数値 (底は e) を返します。 |
double(*1) max(double(*1) a, double(*1) b) | 2 つの double 値のうち大きい方を返します。 |
double(*1) min(double(*1) a, double(*1) b) | 2 つの double 値のうち小さい方を返します。 |
double pow(double a, double b) | 1 番目の引数を、2 番目の引数で累乗した値を返します。 |
double random() | 0.0 以上で、1.0 より小さい正の符号のついた double 値を返します。 |
int(*2) round(float(*2) a) | 引数にもっとも近い int を返します。 |
double sin(double a) | 指定された角度の正弦 (サイン) を返します。 |
double sqrt(double a) | double 値の正しく丸めた正の平方根を返します。 |
double tan(double a) | 指定された角度の正接 (タンジェント) を返します。 |
double toDegrees(double angrad) | ラジアンで計測した角度を、相当する度に変換します。 |
double toRadians(double angdeg) | 度で計測した角度を、相当するラジアンに変換します。 |
- public class Math01 {
- public static void main(String[] args) {
- double d = Double.parseDouble(args[0]);
- System.out.print("Math.round( " + d + ") = " + Math.round(d));
- System.out.print(" ");
- System.out.println(" Math.round(" + (-d) + ") = " + Math.round(-d));
- System.out.print(" Math.ceil( " + d + ") = " + Math.ceil(d));
- System.out.print(" ");
- System.out.println(" Math.ceil(" + (-d) + ") = " + Math.ceil(-d));
- System.out.print("Math.floor( " + d + ") = " + Math.floor(d));
- System.out.print(" ");
- System.out.println("Math.floor(" + (-d) + ") = " + Math.floor(-d));
- System.out.print(" (int)( " + d + ") = " + (int)(d));
- System.out.print(" ");
- System.out.println(" (int)(" + (-d) + ") = " + (int)(-d));
- }
- }
□ 実行結果
$ java Math01 3.14 Math.round( 3.14) = 3 Math.round(-3.14) = -3 Math.ceil( 3.14) = 4.0 Math.ceil(-3.14) = -3.0 Math.floor( 3.14) = 3.0 Math.floor(-3.14) = -4.0 (int)( 3.14) = 3 (int)(-3.14) = -3 $ java Math01 6.5 Math.round( 6.5) = 7 Math.round(-6.5) = -6 Math.ceil( 6.5) = 7.0 Math.ceil(-6.5) = -6.0 Math.floor( 6.5) = 6.0 Math.floor(-6.5) = -7.0 (int)( 6.5) = 6 (int)(-6.5) = -6