BigInteger.Pow(BigInteger, Int32) Methode

Definitie

Hiermee verhoogt u een BigInteger waarde tot de macht van een opgegeven waarde.

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

Parameters

value
BigInteger

Het getal dat tot de exponent macht moet worden verheffen.

exponent
Int32

De exponent om op te heffen value .

Retouren

Het resultaat van het verhogen value van de exponent macht.

Uitzonderingen

exponent is negatief.

Voorbeelden

In het volgende voorbeeld ziet u exponentiatie met behulp van een BigInteger waarde en een exponent waarvan de waarde varieert van 0 tot 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     //
let numericBase = 3040506I

for ctr in 0..10 do
    printfn $"{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     '

Opmerkingen

De Pow methode retourneert 1 als de waarde van de exponentparameter 0 is of als de waarden van zowel de value als exponent de parameters 0 zijn. Als exponent dit 1 is, retourneert Powde value methode . Als value negatief is en exponent oneven is, retourneert de methode een negatief resultaat.

Deze methode komt overeen met de Math.Pow methode voor primitieve numerieke typen.

Van toepassing op