Java.lang.StrictMath 类

java.lang.StrictMath.tanh() 方法返回值的双曲正切。 x 的双曲正切定义为:

tanh

其中 e 是欧拉数。

在特殊情况下,它返回以下内容:

  • 如果参数为 NaN,则结果为 NaN。
  • 如果参数为零,则结果为与参数同号的零。
  • 如果参数为正无穷大,则结果为 +1.0。
  • 如果参数为负无穷大,则结果为 -1.0。

语法

public static double tanh(double x)

参数

x 指定要返回双曲正切的值。

返回值

返回x 的双曲正切。

例外

无。

示例:

在下面的示例中,tanh() 方法用于求出某个值的双曲正切。

import java.lang.*;

public class MyClass {
 public static void main(String[] args) {
  System.out.println(StrictMath.tanh(0));   
  System.out.println(StrictMath.tanh(2));
  System.out.println(StrictMath.tanh(4));     
 }
}

上述代码的输出将是:

0.0
0.9640275800758169
0.999329299739067