java.lang.StrictMath.tanh()%uA0方法返回double值的双曲正切值。 x 的双曲正切定义为%uA0(ex%uA0- e-x)/(ex%uA0+ e-x).它包括以下情况:
- 如果参数为NaN,那么结果为NaN。
- 如果参数是零,那么结果是参数为零相同的符号。
- 如果参数为正无穷大,那么结果是1.0。
- 如果参数为负无穷大,那么结果为-1.0。
声明
以下是java.lang.StrictMath.tanh()方法的声明
public static double tanh(double x)
参数
-
x%uA0-- 这是它的双曲正切是要返回的数。
返回值
此方法返回x的双曲正切值。
异常
-
NA
例子
下面的例子显示java.lang.StrictMath.tanh()方法的使用。
package com.yiibai 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