Java - StrictMath asin(double) 方法



描述

Java StrictMath asin(double a) 方法返回角度的反正弦值,範圍為 -pi/2 到 pi/2。特殊情況:

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

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

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

宣告

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

public static double asin(double a)

引數

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

返回值

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

異常

獲取角度反正弦示例

以下示例顯示了 StrictMath asin() 方法的用法。

package com.tutorialspoint;

public class StrictMathDemo {

   public static void main(String[] args) {

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

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

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

輸出

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

StrictMath.asin(0.027415567780803774)=0.02741900326072046

獲取0°角度反正弦示例

以下示例顯示了 StrictMath asin() 方法在0°角度下的用法。

package com.tutorialspoint;

public class StrictMathDemo {

   public static void main(String[] args) {

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

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

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

輸出

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

StrictMath.asin(0.0)=0.0

獲取45°角度反正弦示例

以下示例顯示了 StrictMath asin() 方法在45°角度下的用法。

package com.tutorialspoint;

public class StrictMathDemo {

   public static void main(String[] args) {

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

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

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

輸出

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

StrictMath.asin(0.7853981633974483)=0.9033391107665127
java_lang_strictmath.htm
廣告
© . All rights reserved.