Java中的 StrictMath asin() 方法及示例
Java.lang.StrictMath.asin()是 StrictMath 类的内置方法,用于返回指定值的反正弦值。返回的角度在-pi/2和pi/2的范围内。该方法产生了两个特殊的结果:
- 如果参数的绝对值大于 1 或参数本身是 NaN,则结果也是 NaN。
- 如果传递的参数为 0,则输出也为 0,其符号与参数相同。
句法 :
public static double asin(double val)
参数:该方法接受一个double类型的参数val ,指的是要返回其反正弦的值。
返回值:该方法返回参数的反正弦值。
例子 :
Input: val = 0.72
Output: 0.80380231893303
Input: val = 7.0
Output: NAN
Input: val = 0.0
Output: 0.0
下面的程序说明了Java.lang.StrictMath.asin() 方法:
方案一:
// Java program to illustrate the
// java.lang.StrictMath.asin()
import java.lang.*;
public class Geeks {
public static void main(String[] args)
{
double val1 = 0.65, val2 = 3.00, val3 = 0;
double asinvalue = StrictMath.asin(val1);
System.out.println(" The arc sine value is = "+
asinvalue);
asinvalue = StrictMath.asin(val2);
System.out.println("The arc sine value is = "+
asinvalue);
asinvalue = StrictMath.asin(val3);
System.out.println("The arc sine value is = "+
asinvalue);
}
}
输出:
The arc sine value is = 0.7075844367253556
The arc sine value is = NaN
The arc sine value is = 0.0
方案二:
// Java program to illustrate the
// java.lang.StrictMath.asin()
import java.lang.*;
public class Geeks {
public static void main(String[] args)
{
double val1 = -0.85, val2 = -2.00, val3 = 0;
double asinvalue = StrictMath.asin(val1);
System.out.println(" The arc sine value is = "+
asinvalue);
asinvalue = StrictMath.asin(val2);
System.out.println("The arc sine value is = "+
asinvalue);
asinvalue = StrictMath.asin(val3);
System.out.println("The arc sine value is= "+
asinvalue);
}
}
输出:
The arc sine value is = -1.015985293814825
The arc sine value is = NaN
The arc sine value is= 0.0