首页 > 编程知识 正文

strictmath_Java StrictMath cosh()方法与示例

时间:2023-05-03 12:12:29 阅读:258587 作者:3809

strictmath

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

cosh() method is available in java.lang package.

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

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

cosh()方法用于返回方法中给定参数角度的双曲余弦值。 在此,“ cosh”代表某个角度的双曲余弦。

cosh() 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.

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

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

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

cosh() method does not throw any exception.

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

Syntax:

句法:

public static double cosh(double d);

Parameter(s):

参数:

double d – represents the value whose hyperbolic cosine of an angle is to be returned.

double d –表示要返回其角度的双曲余弦的值。

Return value:

返回值:

The return type of this method is double – it returns the hyperbolic cosine value of the given argument.

这种方法的返回类型是双 -它返回给定参数的双曲余弦值。

Note:

注意:

If we pass NaN, the method returns NaN.

如果传递NaN,则该方法返回NaN。

If we pass an infinity (positive or negative), the method returns the same value.

如果我们传递无穷大(正数或负数),则该方法将返回相同的值。

If we pass a zero (positive or negative), the method returns the 1.0.

如果传递零(正数或负数),则该方法返回1.0。

Example:

例:

// Java program to demonstrate the example// of cosh(double d) method of StrictMath Class.public class Cosh { public static void main(String[] args) { // variable declarations double d1 = 7.0 / 0.0; double d2 = -7.0 / 0.0; double d3 = 0.0; double d4 = -0.0; double d5 = 60.0; // Display previous value of d1,d2,d3,d4 and d5 System.out.println("d1: " + d1); System.out.println("d2: " + d2); System.out.println("d3: " + d3); System.out.println("d4: " + d4); System.out.println("d5: " + d5); // By using toRadians() method to convert // absolute value into radians. d1 = StrictMath.toRadians(d1); d2 = StrictMath.toRadians(d2); d3 = StrictMath.toRadians(d3); d4 = StrictMath.toRadians(d4); d5 = StrictMath.toRadians(d5); // Here , we will get (infinity) because we are // passing parameter whose value is (infinity) System.out.println("StrictMath.cosh(d1): " + StrictMath.cosh(d1)); // Here , we will get (infinity) because we are // passing parameter whose value is (-infinity) System.out.println("StrictMath.cosh(d2): " + StrictMath.cosh(d2)); // Here , we will get (1.0) because we are // passing parameter whose value is (0.0) System.out.println("StrictMath.cosh(d3): " + StrictMath.cosh(d3)); // Here , we will get (1.0) because we are // passing parameter whose value is (-0.0) System.out.println("StrictMath.cosh(d4): " + StrictMath.cosh(d4)); // Here we will find hyperbolic cosine of d5 by // using cosh() method System.out.println("StrictMath.cosh(d5): " + StrictMath.cosh(d5)); }}

Output

输出量

d1: Infinityd2: -Infinityd3: 0.0d4: -0.0d5: 60.0StrictMath.cosh(d1): InfinityStrictMath.cosh(d2): InfinityStrictMath.cosh(d3): 1.0StrictMath.cosh(d4): 1.0StrictMath.cosh(d5): 1.600286857702386

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

strictmath

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。