在Java中獲取反正弦


要在Java中獲取給定值的反正弦,我們使用java.lang.Math.asin()方法。asin()方法接受一個雙精度值,需要計算其角度。返回角度的範圍在-pi/2到pi/2之間。如果引數是NaN,則結果是NaN。

當引數為零時,輸出為與引數符號相同的零。

宣告 − java.lang.Math.asin()方法宣告如下:

public static double asin(double a)

其中a是需要計算反正弦的值。

讓我們來看一個在Java中獲取給定值反正弦的程式。

示例

 線上演示

import java.lang.Math;
public class Example {
   public static void main(String[] args) {
      // get two double numbers in degrees
      double x = Math.sqrt(3)/2;
      double y = 0.5;
      // computing and displaying the arc sine of these doubles
      System.out.println("Arc sine of " + x + " = " + Math.asin(x));
      System.out.println("Arc sine of " + y + " = " + Math.asin(y));
   }
}

輸出

Arc sine of 0.8660254037844386 = 1.0471975511965976
Arc sine of 0.5 = 0.5235987755982989

更新於:2020年6月26日

181 次瀏覽

啟動您的職業生涯

完成課程獲得認證

開始學習
廣告