Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> C#

เมธอด MathF.Cosh() ใน C# พร้อมตัวอย่าง


เมธอด MathF.Cosh() ใน C# ใช้สำหรับส่งคืนโคไซน์ไฮเปอร์โบลิกของค่าจุดทศนิยม

ไวยากรณ์

public static float Cosh (float val);

พารามิเตอร์ val คือจำนวนจุดทศนิยม

ตัวอย่าง

using System; 
class Demo { 
    public static void Main(){ 
        float val = 45.0f; 
        float res = MathF.Cosh(val); 
        Console.WriteLine("Cosh = " + res); 
    } 
}

ผลลัพธ์

Cosh = 1.746714E+19

ตัวอย่างที่ 2

using System; 
class Demo { 
    public static void Main(){ 
        float val = 90f; 
        float res = MathF.Cosh(val); 
        Console.WriteLine("Cosh = " + res); 
    } 
}

ผลลัพธ์

Cosh = Infinity