Java - StrictMath toRadians(double x) 方法



描述

Java StrictMath toRadians(double angdeg) 方法將以度為單位測量的角度轉換為近似等效的以弧度為單位測量的角度。度到弧度的轉換通常是不精確的。

宣告

以下是java.lang.StrictMath.toRadians() 方法的宣告

public static double toRadians(double angdeg)

引數

angdeg − 以度為單位的角度

返回值

此方法返回以弧度表示的角度 angdeg 的度量。

異常

示例:獲取正雙精度值的弧度

以下示例顯示了對正雙精度值使用 StrictMath toRadians() 方法。

package com.tutorialspoint;
public class StrictMathDemo {
   public static void main(String[] args) {

      // get a double number
      double x = 45.0;

      // print the radian for this double
      System.out.println("StrictMath.toRadians(" + x + ")=" + StrictMath.toRadians(x));
   }
}

輸出

讓我們編譯並執行上面的程式,這將產生以下結果:

StrictMath.toRadians(45.0)=0.7853981633974483

示例:獲取負雙精度值的弧度

以下示例顯示了使用 StrictMath toRadians() 方法獲取負雙精度值的弧度。

package com.tutorialspoint;
public class StrictMathDemo {
   public static void main(String[] args) {

      // get a double number
      double x = -45.0;

      // print the radian for this double
      System.out.println("StrictMath.toRadians(" + x + ")=" + StrictMath.toRadians(x));
   }
}

輸出

讓我們編譯並執行上面的程式,這將產生以下結果:

StrictMath.toRadians(-45.0)=-0.7853981633974483

示例:獲取零雙精度值的弧度

以下示例顯示了使用 StrictMath toRadians() 方法獲取零雙精度值的弧度。

package com.tutorialspoint;
public class StrictMathDemo {
   public static void main(String[] args) {

      // get a double number
      double x = 0.0;

      // print the radian for this double
      System.out.println("StrictMath.toRadians(" + x + ")=" + StrictMath.toRadians(x));
   }
}

輸出

讓我們編譯並執行上面的程式,這將產生以下結果:

StrictMath.toRadians(0.0)=0.0
java_lang_strictmath.htm
廣告