java.lang.Math.asin()返回介於-pi /2和pi /2之間的角度的反正弦。反正弦也稱為正弦的逆。
如果參數為NaN或其絕對值大於1,則結果為NaN。
如果自變量為零,則結果為零,其符號與自變量相同。
用法:
public static double asin(double angle)
Parameter:
angle: the value whose arc sine is to be returned.
返回:
此方法返回參數的反正弦值。
範例1:展示java.lang.Math.asin()方法的用法。
// Java program to demonstrate working
// of java.lang.Math.asin() method
import java.lang.Math;
class Gfg {
// driver code
public static void main(String args[])
{
double a = Math.PI;
// Output is NaN, because Math.PI gives 3.141 value
// greater than 1
System.out.println(Math.asin(a));
// convert Math.PI to radians
double b = Math.toRadians(a);
System.out.println(Math.asin(b));
double c = 1.0;
System.out.println(Math.asin(c));
double d = 0.0;
System.out.println(Math.asin(d));
double e = -1.0;
System.out.println(Math.asin(e));
double f = 1.5;
// value of f does not lie in between -1 and 1
// so output is NaN
System.out.println(Math.asin(f));
}
}
輸出:
NaN
0.054858647341251204
1.5707963267948966
0.0
-1.5707963267948966
NaN