在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
广告
数据结构
网络
关系型数据库管理系统 (RDBMS)
操作系统
Java
iOS
HTML
CSS
Android
Python
C语言编程
C++
C#
MongoDB
MySQL
Javascript
PHP