在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) {
//得到两个双度数
double x = Math.sqrt(3)/2;
double y = 0.5;
//计算并显示这些双打的反正弦
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