BigInteger.Pow(BigInteger, Int32) 方法
定义
求以 BigInteger 值为底、以指定的值为指数的幂。Raises a BigInteger value to the power of a specified value.
public:
static System::Numerics::BigInteger Pow(System::Numerics::BigInteger value, int exponent);
public static System.Numerics.BigInteger Pow (System.Numerics.BigInteger value, int exponent);
static member Pow : System.Numerics.BigInteger * int -> System.Numerics.BigInteger
Public Shared Function Pow (value As BigInteger, exponent As Integer) As BigInteger
参数
- value
- BigInteger
要计算 exponent
次幂的数字。The number to raise to the exponent
power.
- exponent
- Int32
对 value
进行幂运算的指数。The exponent to raise value
by.
返回
value
的 exponent
次幂的计算结果。The result of raising value
to the exponent
power.
例外
exponent
为负数。exponent
is negative.
示例
下面的示例演示了使用 BigInteger 值和其值范围从0到10的指数的幂运算。The following example illustrates exponentiation using a BigInteger value and an exponent whose value ranges from 0 to 10.
BigInteger numericBase = 3040506;
for (int ctr = 0; ctr <= 10; ctr++)
{
Console.WriteLine(BigInteger.Pow(numericBase, ctr));
}
//
// The example produces the following output to the console:
//
// 1
// 3040506
// 9244676736036
// 28108495083977874216
// 85464047953805230420993296
// 259853950587832525926412642447776
// 790087495886008322074413197838317614656
// 2402265771766383619317185774506591737267255936
// 7304103492650319992835619250501939216711515276943616
// 22208170494024253840136657344866649200046662468638726109696
// 67524075636103707946458547477011116092637077515870858568887346176 //
Dim base As BigInteger = 3040506
For ctr As Integer = 0 To 10
Console.WriteLine(BigInteger.Pow(base, ctr))
Next
'
' The example produces the following output to the console:
'
' 1
' 3040506
' 9244676736036
' 28108495083977874216
' 85464047953805230420993296
' 259853950587832525926412642447776
' 790087495886008322074413197838317614656
' 2402265771766383619317185774506591737267255936
' 7304103492650319992835619250501939216711515276943616
' 22208170494024253840136657344866649200046662468638726109696
' 67524075636103707946458547477011116092637077515870858568887346176 '
注解
Pow如果指数参数的值为0,或者 value
和参数的值均为0,则此方法返回 1 exponent
。The Pow method returns 1 if the value of the exponent parameter is 0, or if the values of both the value
and exponent
parameters are 0. 如果 exponent
为1,则该 Pow 方法返回 value
。If exponent
is 1, the Pow method returns value
. 如果 value
为负,则该方法返回一个负面结果。If value
is negative, the method returns a negative result.
此方法对应于 Math.Pow 基元数值类型的方法。This method corresponds to the Math.Pow method for primitive numeric types.