Groovy-sin

提供:Dev Guides
移動先:案内検索

グルーヴィー-sin()

このメソッドは、指定されたdouble値のサインを返します。

構文

double sin(double d)

パラメーター

d-doubleデータ型。

戻り値

このメソッドは、指定されたdouble値のサインを返します。

以下は、このメソッドの使用例です-

class Example {
   static void main(String[] args) {
      double degrees = 45.0;
      double radians = Math.toRadians(degrees);

      System.out.format("The value of pi is %.4f%n", Math.PI);
      System.out.format("The sine of %.1f degrees is %.4f%n", degrees, Math.sin(radians));
   }
}

上記のプログラムを実行すると、次の結果が得られます-

The value of pi is 3.1416
The sine of 45.0 degrees is 0.7071