BigInteger.Remainder(BigInteger, BigInteger) Methode
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Führt die Ganzzahldivision von zwei BigInteger-Werten aus und gibt den Rest zurück.
public:
static System::Numerics::BigInteger Remainder(System::Numerics::BigInteger dividend, System::Numerics::BigInteger divisor);
public static System.Numerics.BigInteger Remainder (System.Numerics.BigInteger dividend, System.Numerics.BigInteger divisor);
static member Remainder : System.Numerics.BigInteger * System.Numerics.BigInteger -> System.Numerics.BigInteger
Public Shared Function Remainder (dividend As BigInteger, divisor As BigInteger) As BigInteger
Parameter
- dividend
- BigInteger
Der zu dividierende Wert.
- divisor
- BigInteger
Der Wert, durch den dividiert werden soll.
Gibt zurück
Der Rest aus der Division von dividend
durch divisor
.
Ausnahmen
divisor
ist 0 (null).
Beispiele
Im folgenden Beispiel wird der Rest der Methode mit dem DivRem Rest verglichen, der von der Remainder -Methode zurückgegeben wird, um festzustellen, dass die beiden Methoden identische Reste berechnen.
using System;
using System.Numerics;
public class Example
{
public static void Main()
{
BigInteger dividend1 = BigInteger.Pow(Int64.MaxValue, 3);
BigInteger dividend2 = dividend1 * BigInteger.MinusOne;
BigInteger divisor1 = Int32.MaxValue;
BigInteger divisor2 = divisor1 * BigInteger.MinusOne;
BigInteger remainder1, remainder2;
BigInteger divRem1 = BigInteger.Zero;
BigInteger divRem2 = BigInteger.Zero;
remainder1 = BigInteger.Remainder(dividend1, divisor1);
remainder2 = BigInteger.Remainder(dividend2, divisor1);
BigInteger.DivRem(dividend1, divisor1, out divRem1);
Console.WriteLine("BigInteger.Remainder({0}, {1}) = {2}",
dividend1, divisor1, remainder1);
Console.WriteLine("BigInteger.DivRem({0}, {1}) = {2}",
dividend1, divisor1, divRem1);
if (remainder1.Equals(divRem1))
Console.WriteLine("The remainders are equal.\n");
BigInteger.DivRem(dividend2, divisor2, out divRem2);
Console.WriteLine("BigInteger.Remainder({0}, {1}) = {2}",
dividend2, divisor2, remainder2);
Console.WriteLine("BigInteger.DivRem({0}, {1}) = {2}",
dividend2, divisor2, divRem2);
if (remainder2.Equals(divRem2))
Console.WriteLine("The remainders are equal.\n");
}
}
// The example displays the following output:
// BigInteger.Remainder(784637716923335095224261902710254454442933591094742482943, 2147483647) = 1
// BigInteger.DivRem(784637716923335095224261902710254454442933591094742482943, 2147483647) = 1
// The remainders are equal.
//
// BigInteger.Remainder(-784637716923335095224261902710254454442933591094742482943, -2147483647) = -1
// BigInteger.DivRem(-784637716923335095224261902710254454442933591094742482943, -2147483647) = -1
// The remainders are equal.
open System
open System.Numerics
let dividend1 = BigInteger.Pow(Int64.MaxValue, 3)
let dividend2 = dividend1 * BigInteger.MinusOne
let divisor1 = bigint Int32.MaxValue
let divisor2 = divisor1 * BigInteger.MinusOne
let remainder1 = BigInteger.Remainder(dividend1, divisor1)
let remainder2 = BigInteger.Remainder(dividend2, divisor1)
let mutable divRem1 = BigInteger.Zero
let mutable divRem2 = BigInteger.Zero
BigInteger.DivRem(dividend1, divisor1, &divRem1) |> ignore
printfn $"BigInteger.Remainder({dividend1}, {divisor1}) = {remainder1}"
printfn $"BigInteger.DivRem({dividend1}, {divisor1}) = {divRem1}"
if remainder1.Equals divRem1 then
printfn $"The remainders are equal.\n"
BigInteger.DivRem(dividend2, divisor2, &divRem2) |> ignore
printfn $"BigInteger.Remainder({dividend2}, {divisor2}) = {remainder2}"
printfn $"BigInteger.DivRem({dividend2}, {divisor2}) = {divRem2}"
if remainder2.Equals divRem2 then
printfn $"The remainders are equal.\n"
// The example displays the following output:
// BigInteger.Remainder(784637716923335095224261902710254454442933591094742482943, 2147483647) = 1
// BigInteger.DivRem(784637716923335095224261902710254454442933591094742482943, 2147483647) = 1
// The remainders are equal.
//
// BigInteger.Remainder(-784637716923335095224261902710254454442933591094742482943, -2147483647) = -1
// BigInteger.DivRem(-784637716923335095224261902710254454442933591094742482943, -2147483647) = -1
// The remainders are equal.
Imports System.Numerics
Module Example
Public Sub Main()
Dim dividend1 As BigInteger = BigInteger.Pow(Int64.MaxValue, 3)
Dim dividend2 As BigInteger = dividend1 * BigInteger.MinusOne
Dim divisor1 As BigInteger = Int32.MaxValue
Dim divisor2 As BigInteger = divisor1 * BigInteger.MinusOne
Dim remainder1, remainder2 As BigInteger
Dim divRem1 As BigInteger = BigInteger.Zero
Dim divRem2 As BigInteger = BigInteger.Zero
remainder1 = BigInteger.Remainder(dividend1, divisor1)
remainder2 = BigInteger.Remainder(dividend2, divisor1)
BigInteger.DivRem(dividend1, divisor1, divRem1)
Console.WriteLine("BigInteger.Remainder({0}, {1}) = {2}",
dividend1, divisor1, remainder1)
Console.WriteLine("BigInteger.DivRem({0}, {1}) = {2}",
dividend1, divisor1, divRem1)
If remainder1.Equals(divRem1) Then Console.WriteLine("The remainders are equal.")
Console.WriteLine()
BigInteger.DivRem(dividend2, divisor2, divRem2)
Console.WriteLine("BigInteger.Remainder({0}, {1}) = {2}",
dividend2, divisor2, remainder2)
Console.WriteLine("BigInteger.DivRem({0}, {1}) = {2}",
dividend2, divisor2, divRem2)
If remainder2.Equals(divRem2) Then Console.WriteLine("The remainders are equal.")
Console.WriteLine()
End Sub
End Module
' The example displays the following output:
' BigInteger.Remainder(784637716923335095224261902710254454442933591094742482943, 2147483647) = 1
' BigInteger.DivRem(784637716923335095224261902710254454442933591094742482943, 2147483647) = 1
' The remainders are equal.
'
' BigInteger.Remainder(-784637716923335095224261902710254454442933591094742482943, -2147483647) = -1
' BigInteger.DivRem(-784637716923335095224261902710254454442933591094742482943, -2147483647) = -1
' The remainders are equal.
Hinweise
Das Vorzeichen des restlichen Werts ist das Zeichen des dividend
Parameters.
Die Remainder -Methode wird für Sprachen implementiert, die keine benutzerdefinierten Operatoren unterstützen. Sein Verhalten ist identisch mit der Division mit dem Modulus-Operator.
Bei Bedarf führt die Methode automatisch eine implizite Konvertierung anderer integraler Typen in Objekte durch BigInteger , bevor sie den Modulusvorgang ausführt.