Java - Math asin(double) 方法



描述

Java Math asin(double a) 返回角度的反正弦值,範圍在 -pi/2 到 pi/2 之間。特殊情況:

  • 如果引數是 NaN 或其絕對值大於 1,則結果為 NaN。

  • 如果引數為零,則結果為與引數符號相同的零。

結果必須在正確舍入結果的 1 ulp 範圍內。結果必須是半單調的。

宣告

以下是java.lang.Math.asin() 方法的宣告

public static double asin(double a)

引數

a − 將返回其反正弦的值。

返回值

此方法返回引數的反正弦。

異常

獲取角度反正弦示例

以下示例演示了 Math asin() 方法的使用。

package com.tutorialspoint;

public class MathDemo {

   public static void main(String[] args) {

      // get a variable x which is equal to PI/2
      double x = Math.PI / 2;

      // convert x to radians
      x = Math.toRadians(x);

      // get the arc sine of x
      System.out.println("Math.asin(" + x + ")=" + Math.asin(x));
   }
}

輸出

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

Math.asin(0.027415567780803774)=0.02741900326072046

獲取0°角的反正弦示例

以下示例演示了 0°角的 Math asin() 方法的使用。

package com.tutorialspoint;

public class MathDemo {

   public static void main(String[] args) {

      // get a variable x which is equal to zero
      double x = 0.0d;

      // convert x to radians
      x = Math.toRadians(x);

      // get the arc sine of x
      System.out.println("Math.asin(" + x + ")=" + Math.asin(x));
   }
}

輸出

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

Math.asin(0.0)=0.0

獲取45°角的反正弦示例

以下示例演示了 45°角的 Math asin() 方法的使用。

package com.tutorialspoint;

public class MathDemo {

   public static void main(String[] args) {

      // get a variable x which is equal to zero
      double x = 45.0d;

      // convert x to radians
      x = Math.toRadians(x);

      // get the arc sine of x
      System.out.println("Math.asin(" + x + ")=" + Math.asin(x));
   }
}

輸出

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

Math.asin(0.7853981633974483)=0.9033391107665127
java_lang_math.htm
廣告