Java.lang.StrictMath.acos() 方法
描述
java.lang.StrictMath.acos() 方法返回一个值的反余弦值,返回的角度在 0.0 到 pi 的范围内。 如果参数为 NaN 或其绝对值大于 1,则结果为 NaN。
声明
以下是 java.lang.StrictMath.acos() 方法的声明。
public static double acos(double a)
参数
a − 这是要返回其反余弦的值。
返回值
此方法返回参数的反余弦值。
异常
NA
示例
下面的例子展示了 java.lang.StrictMath.acos() 方法的使用。
package com.tutorialspoint;
import java.lang.*;
public class StrictMathDemo {
public static void main(String[] args) {
double d1 = 0.90 , d2 = 5.00;
// returns the arc cosine of a value
double dAbsValue = StrictMath.acos(d1);
System.out.println("arc cosine value of " + d1 + " = " + dAbsValue);
// returns NaN if argument is NaN or its absolute value is greater than 1
dAbsValue = StrictMath.acos(d2);
System.out.println("arc cosine value of " + d2 + " = " + dAbsValue);
}
}
让我们编译并运行上面的程序,这将产生下面的结果 −
cosine value of 0.9 = 0.45102681179626236 cosine value of 5.0 = NaN

