Math.Cosh(Single)方法是內置的MathF類方法,它返回給定單值參數的雙曲餘弦值。
用法: public static float Cosh (float x);
Here, x is the number whose hyperbolic cosine 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.Cosh(Single) Method
using System;
class GFG {
// Main Method
public static void Main(String[] args)
{
float num1 = 60.0f, num2 = 0.0f, num3 = 1.0f;
// It returns the hyperbolic cosine
// of specified angle in radian
float coshvalue = MathF.Cosh(num1);
Console.WriteLine("The Cosh of num1 = " + coshvalue);
coshvalue = MathF.Cosh(num2);
Console.WriteLine("The Cosh of num2 = " + coshvalue);
coshvalue = MathF.Cosh(num3);
Console.WriteLine("The Cosh of num3 = " + coshvalue);
}
}
輸出:
The Cosh of num1 = 5.710037E+25 The Cosh of num2 = 1 The Cosh of num3 = 1.543081
示例2:
// C# praogram to illustrate the
// MathF.Cosh(Single) Method
using System;
class GFG {
// Main Method
public static void Main()
{
float num1 = (30 * (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.Cosh(value);
// Display the value
Console.WriteLine("Cosh({0}) will be {1}",
value, result);
}
}
輸出:
Cosh(0.5235988) will be 1.140238 Cosh(NaN) will be NaN Cosh(-Infinity) will be Infinity Cosh(Infinity) will be Infinity
相關用法
- C# MathF.Exp()用法及代碼示例
- C# MathF.Cos()用法及代碼示例
- C# MathF.Tan()用法及代碼示例
- C# MathF.Abs()用法及代碼示例
- C# MathF.Min()用法及代碼示例
- C# MathF.Sin()用法及代碼示例
- C# MathF.Pow()用法及代碼示例
- C# MathF.Log()用法及代碼示例
- C# MathF.Max()用法及代碼示例
- C# MathF.Cbrt()用法及代碼示例
- C# Char.GetTypeCode()用法及代碼示例
- C# Char.GetHashCode()用法及代碼示例
- C# MathF.Atan()用法及代碼示例
- C# BitArray.RightShift()用法及代碼示例
- C# BitArray.LeftShift()用法及代碼示例
注:本文由純淨天空篩選整理自Kirti_Mangal大神的英文原創作品 MathF.Cosh() Method in C# with Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。