BigInteger.Pow(BigInteger, Int32) 方法

定義

BigInteger 值自乘至指定之值的乘冪。

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 的數字。

exponent
Int32

value 的乘冪指數。

傳回

value 自乘至 exponent 乘冪的結果。

例外狀況

exponent 為負。

範例

下列範例說明使用 BigInteger 值和值範圍從 0 到 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     '

備註

如果指數參數的值是 0,或者 和 exponent 參數的值value都是 0,則Pow方法會傳回 1。 如果 exponent 為 1,則 Pow 方法會傳 value回 。 如果 value 為負數,則方法會傳回負結果。

這個方法會對應至 Math.Pow 基本數值類型的方法。

適用於