Java - StrictMath toDegrees(double x) 方法



描述

Java StrictMath toDegrees(double angrad) 方法將以弧度為單位測量的角度轉換為近似等效的以度為單位測量的角度。從弧度到度的轉換通常是不精確的;使用者不應期望 cos(toRadians(90.0)) 完全等於 0.0。

宣告

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

public static double toDegrees(double angrad)

引數

angrad − 以弧度為單位的角度

返回值

此方法返回以度為單位的角度 angrad 的度量。

異常

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

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

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

      // get a double number
      double x = 45.0;

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

輸出

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

StrictMath.toDegrees(45.0)=2578.3100780887044

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

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

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

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

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

輸出

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

StrictMath.toDegrees(-45.0)=-2578.3100780887044

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

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

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

      // get a double number
      double x = 0.0;

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

輸出

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

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