strictmath_Java StrictMath tanh()方法与示例

strictmath

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

  • tanh() method is available in java.lang package.

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

  • tanh() method is used to return the hyperbolic tangent of an angle of the given parameter in the method or in other words, it returns [sinh(d)/cosh(d)]. Here, "tanh" stands for the hyperbolic tangent of an angle.

    tanh()方法用于返回该方法中给定参数角度的双曲正切值,换句话说,它返回[ sinh(d) / cosh(d) ]。 在此,“ tanh”代表某个角度的双曲正切。

  • tanh() 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 any error.

    tanh()方法是静态方法,因此可以使用类名称进行访问,如果尝试使用类对象访问该方法,则不会出现任何错误。

  • 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 tanh() method).

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

  • tanh() method does not throw any exception at the time of returning hyperbolic tangent of the given angle.

    在返回给定角度的双曲正切时, tanh()方法不会引发任何异常。

Syntax:

句法:

    public static double tanh(double d);

Parameter(s):

参数:

  • double d – represents the value hyperbolic tangent is to be returned.

    double d –表示要返回的双曲正切值。

Return value:

返回值:

The return type of this method is double – it returns the hyperbolic tangent of the given angle.

这种方法的返回类型是双 -它返回给定角度的双曲正切。

Note:

注意:

  • If we pass NaN, the method returns NaN.

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

  • If we pass an infinity (positive or negative), the method returns 1.0.

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

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

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

Example:

例:

// Java program to demonstrate the example of 
// tanh(double d) method of StrictMath class.

public class Tanh {
    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 (1.0) because we are passing parameter 
        // whose value is (infinity)
        System.out.println("StrictMath.tanh (d1): " + StrictMath.tanh(d1));

        // Here , we will get (-1.0) because we are passing parameter 
        // whose value is (-infinity)
        System.out.println("StrictMath.tanh (d2): " + StrictMath.tanh(d2));

        // Here , we will get (0.0) because we are passing parameter
        // whose value is (0.0)
        System.out.println("StrictMath.tanh (d3): " + StrictMath.tanh(d3));

        // Here , we will get (-0.0) because we are passing parameter 
        // whose value is (-0.0)
        System.out.println("StrictMath.tanh (d4): " + StrictMath.tanh(d4));

        // Here we will find hyperbolic tangent of d5 by 
        // using tanh () method
        System.out.println("StrictMath.tanh (d5): " + StrictMath.tanh(d5));
    }
}

Output

输出量

d1: Infinity
d2: -Infinity
d3: 0.0
d4: -0.0
d5: 60.0
StrictMath.tanh (d1): 1.0
StrictMath.tanh (d2): -1.0
StrictMath.tanh (d3): 0.0
StrictMath.tanh (d4): -0.0
StrictMath.tanh (d5): 0.7807144353592677


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

strictmath

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值