当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Java StrictMath cosh()用法及代码示例


java.lang.StrictMath.cosh()是Java中的内置方法,该方法返回给定double参数的双曲余弦值。

  • 当参数为NaN时,该方法返回NaN。
  • 当参数为无穷大时,该方法返回正无穷大。
  • 当给定参数为0.0时,该方法返回1.0。

用法:

public static double cosh(double num)

参数:该方法接受一个双精度类型的参数num,其双曲余弦值将被返回。


返回值:该方法返回num的双曲余弦值。

例子:

Input: num = 60.0
Output: 5.710036949078421E25

Input: num = 0.0
Output: 1.0

下面的程序演示了java.lang.StrictMath.cosh()方法:
示例1:

// Java praogram to illustrate the 
// java.lang.StrictMath.cosh() 
import java.lang.*; 
  
public class Geeks { 
  
    public static void main(String[] args) 
    { 
  
        double num1 = 78.8, num2 = 0.0, num3 = 1.0; 
  
        // It returns the hyperbolic cosine of 
        // specified angle in radian 
        double coshvalue = StrictMath.cosh(num1); 
        System.out.println("The cosh of "+ 
                     num1+" = " + coshvalue); 
  
        coshvalue = StrictMath.cosh(num2); 
        System.out.println("The cosh of "+ 
                     num2+" = " + coshvalue); 
  
        coshvalue = StrictMath.cosh(num3); 
        System.out.println("The cosh of "+ 
                     num3+" = " + coshvalue); 
    } 
}
输出:
The cosh of 78.8 = 8.344016962852523E33
The cosh of 0.0 = 1.0
The cosh of 1.0 = 1.543080634815244

示例2:

// Java praogram to illustrate the 
// java.lang.StrictMath.cosh() 
import java.lang.*; 
  
public class Geeks { 
  
    public static void main(String[] args) 
    { 
  
        double num1 = (30 * (Math.PI)) / 180; 
        double num2 = 11.0, num3 = 45.0; 
  
        // It returns the hyperbolic cosine of  
        // angle in radian 
        double coshvalue = StrictMath.cosh(num1); 
        System.out.println("The cosh of "+ 
                     num1+" = " + coshvalue); 
  
        coshvalue = StrictMath.cosh(num2); 
        System.out.println("The cosh of "+ 
                     num2+" = " + coshvalue); 
  
        coshvalue = StrictMath.cosh(num3); 
        System.out.println("The cosh of "+ 
                     num3+" = " + coshvalue);     
    } 
}
输出:
The cosh of 0.5235987755982988 = 1.1402383210764286
The cosh of 11.0 = 29937.070865949758
The cosh of 45.0 = 1.7467135528742547E19


相关用法


注:本文由纯净天空筛选整理自ankita_chowrasia大神的英文原创作品 StrictMath cosh() Method in Java。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。