📜  C#中的MathF.Pow()方法与示例

📅  最后修改于: 2021-05-29 20:54:56             🧑  作者: Mango

在C#中, MathF.Pow(Single,Single)是MathF类方法。此方法用于计算将数字提高到其他数字的乘方。

返回类型:函数返回加到幂的底数。此方法的返回类型为System.Single

例子:

// C# program to illustrate the
// MathF.Pow(Single, Single) Method
using System;
  
class GFG {
  
    // Main Method
    static public void Main()
    {
  
        // Find power using MathF.Pow
        // 8 is base and 4 is power or
        // index or exponent of a number
        float pow_ab = MathF.Pow(8f, 4f);
  
        // Print the result
        Console.WriteLine(pow_ab);
  
        // 7.5 is base and 2 is power or
        // index or exponent of a number
        float pow_tt = MathF.Pow(7.5f, 2f);
  
        // Print the result
        Console.WriteLine(pow_tt);
  
        // 1234 is base and 7 is power or
        // index or exponent of a number
        float pow_t = MathF.Pow(1234f, 7f);
  
        // Print the result
        Console.WriteLine(pow_t);
    }
}
输出:
4096
56.25
4.357186E+21