เมธอด MathF.Exp() ใน C# จะคืนค่ายกกำลังที่ระบุ
ไวยากรณ์
ต่อไปนี้เป็นไวยากรณ์ -
public static float Exp (float val);
ด้านบน Val คือเลขทศนิยม
ตัวอย่าง
ให้เรามาดูตัวอย่างการใช้งาน MathF.Exp() method −
using System;
class Demo {
public static void Main(){
float val = 90f;
float res = MathF.Exp(val);
Console.WriteLine("MathF.Exp() = "+res);
}
} ผลลัพธ์
สิ่งนี้จะสร้างผลลัพธ์ต่อไปนี้ -
MathF.Exp() = Infinity
ตัวอย่าง
ให้เราดูตัวอย่างอื่นเพื่อนำวิธีการ MathF.Exp() ไปใช้ −
using System;
class Demo {
public static void Main(){
float val = 0.00f;
float res = MathF.Exp(val);
Console.WriteLine("MathF.Exp() = "+res);
}
} ผลลัพธ์
สิ่งนี้จะสร้างผลลัพธ์ต่อไปนี้ -
MathF.Exp() = 1