static double tanh(double x)
描述 (Description)
java.lang.StrictMath.tanh()方法返回double值的双曲正切值。 x的双曲正切定义为(e x - e -x )/(e x + e -x )包括这些情况 -
- 如果参数是NaN,则结果为NaN。
- 如果参数为零,则结果为零,其参数符号相同。
- 如果参数为正无穷大,则结果为+1.0。
- 如果参数为负无穷大,则结果为-1.0。
声明 (Declaration)
以下是java.lang.StrictMath.tanh()方法的声明
public static double tanh(double x)
参数 (Parameters)
x - 这是要返回双曲正切的数字。
返回值 (Return Value)
此方法返回x的双曲正切值。
异常 (Exception)
NA
例子 (Example)
以下示例显示了java.lang.StrictMath.tanh()方法的用法。
package com.iowiki;
import java.lang.*;
public class StrictMathDemo {
public static void main(String[] args) {
double d1 = (90*Math.PI)/180 , d2 = 0.0;
double d3 = (1.0)/(0.0), d4 = -(1.0)/(0.0);
// returns the hyperbolic trigonometric tangent of an angle.
double tanhValue = StrictMath.tanh(d1);
System.out.println("hyperbolic tangent of d1 = " + tanhValue);
tanhValue = StrictMath.tanh(d2);
System.out.println("hyperbolic tangent of d2 = " + tanhValue);
tanhValue = StrictMath.tanh(d3);
System.out.println("hyperbolic tangent of d3 = " + tanhValue);
tanhValue = StrictMath.tanh(d4);
System.out.println("hyperbolic tangent of d4 = " + tanhValue);
}
}
让我们编译并运行上面的程序,这将产生以下结果 -
hyperbolic tangent of d1 = 0.9171523356672744
hyperbolic tangent of d2 = 0.0
hyperbolic tangent of d3 = 1.0
hyperbolic tangent of d4 = -1.0