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


C# MathF.Sinh()用法及代码示例


Math.Sinh(Single)方法是内置的MathF类方法,它返回给定单值参数的双曲正弦值。

用法: public static float Sinh (float x);
Here, x is the number whose hyperbolic sine is to be returned and type of this parameter is System.Single.

返回值:此方法返回System.Single类型的x的双曲正弦值。如果x等于NegativeInfinity或PositiveInfinity,则返回PositiveInfinity。如果x等于NaN,则返回NaN。


以下示例程序旨在说明上述方法的用法:

示例1:

// C# program to illustrate the 
// MathF.Sinh(Single) Method 
using System; 
  
class GFG { 
  
    // Main Method 
    public static void Main(String[] args) 
    { 
  
        float num1 = 45.0f, num2 = 0.0f, num3 = 1.0f; 
  
        // It returns the hyperbolic sine of 
        // specified angle in radian 
        float sinhvalue = MathF.Sinh(num1); 
        Console.WriteLine("The Sinh of num1 = " + sinhvalue); 
  
        sinhvalue = MathF.Sinh(num2); 
        Console.WriteLine("The Sinh of num2 = " + sinhvalue); 
  
        sinhvalue = MathF.Sinh(num3); 
        Console.WriteLine("The Sinh of num3 = " + sinhvalue); 
    } 
}
输出:
The Sinh of num1 = 1.746714E+19
The Sinh of num2 = 0
The Sinh of num3 = 1.175201

示例2:

// C# praogram to illustrate the 
// MathF.Sinh(Single) Method 
using System; 
  
class GFG { 
  
    // Main Method 
    public static void Main() 
    { 
          
        float num1 = (60 * (MathF.PI)) / 180; 
          
        // calling result() method 
        result(num1); 
        result(Single.NaN); 
        result(Single.NegativeInfinity); 
        result(Single.PositiveInfinity); 
    } 
  
    // defining result() method 
    public static void result(float value) 
    { 
  
        // using the method 
        float result = MathF.Sinh(value); 
  
        // Display the value 
        Console.WriteLine("Sinh({0}) will be {1}", 
                                value, result); 
    } 
}
输出:
Sinh(1.047198) will be 1.249367
Sinh(NaN) will be NaN
Sinh(-Infinity) will be -Infinity
Sinh(Infinity) will be Infinity


相关用法


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