strictmath_Java StrictMath acos()方法与示例

strictmath

StrictMath类acos()方法 (StrictMath Class acos() method)

  • acos() method is available in java.lang package.

    acos()方法在java.lang包中可用。

  • acos() method is used to return the arc cosine of the given parameter in the method. Here, acos stands for "arc cosine" of an angle.

    acos()方法用于返回方法中给定参数的反余弦值 。 在这里, acos代表一个角度的“弧余弦”

  • acos() method is a static method so it is accessible with the class name and if we try to access the method with the class object then we will not get an error.

    acos()方法是一个静态方法,因此可以使用类名进行访问,如果尝试使用类对象访问该方法,则不会收到错误。

  • In this method, we pass only radians type argument (i.e. First we convert given argument in radians by using toRadians() method of Math class then after we will pass the same variable in acos() method).

    在此方法中,我们仅传递弧度类型的参数(即,首先,我们使用Math类的toRadians()方法将给定的参数转换为弧度,然后在acos()方法中传递相同的变量)。

  • acos() method does not throw any exception.

    acos()方法不会引发任何异常。

  • In this method, the meaning of arc cosine is the inverse or reverse cosine of the given argument.

    在这种方法中,反余弦的含义是给定参数的反余弦。

  • The range of acos() lies 0.0 through PI.

    acos()的范围通过PI为0.0。

Syntax:

句法:

    public static double acos(double d);

Parameter(s):

参数:

  • double d – represents a double type value whose arc cosine value to be found.

    double d –表示其反余弦值的double类型值。

Return value:

返回值:

The return type of this method is double – it returns the arc cosine of given angle.

此方法的返回类型是双 -返回给定角度的余弦值。

Note:

注意:

  • If we pass NaN as an argument, method returns the same value (NaN).

    如果我们将NaN作为参数传递,则方法将返回相同的值(NaN)。

  • If we pass an argument whose absolute value is greater than 1, method returns NaN.

    如果我们传递一个绝对值大于1的参数,则方法返回NaN。

Example:

例:

// Java program to demonstrate the example
// of  acos(double d) method of StricMath Class.

public class Acos {
    public static void main(String[] args) {
        // variable declarations
        double a1 = 100;
        double a2 = Math.PI / 2;

        // Display previous value of a1 and a2
        System.out.println("a1 :" + a1);
        System.out.println("a2:" + a2);

        // Here , we will get NaN because we are 
        // passing parameter whose absolute value is greater
        // than 1
        System.out.println("StrictMath.acos(a1): " + StrictMath.acos(a1));

        // By using toRadians() method is used to convert absolute to radians
        a2 = StrictMath.toRadians(a2);

        // Display the value of a2 in radians form
        System.out.println("StrictMath.toRadians(a2): " + a2);

        // Here we will find arc cosine of a2 by using acos() method
        System.out.println("StrictMath.acos(a2): " + StrictMath.acos(a2));
    }
}

Output

输出量

a1 :100.0
a2:1.5707963267948966
StrictMath.acos(a1): NaN
StrictMath.toRadians(a2): 0.027415567780803774
StrictMath.acos(a2): 1.5433773235341761


翻译自: https://www.includehelp.com/java/strictmath-acos-method-with-example.aspx

strictmath

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值