BigInteger.Remainder(BigInteger, BigInteger) BigInteger.Remainder(BigInteger, BigInteger) BigInteger.Remainder(BigInteger, BigInteger) BigInteger.Remainder(BigInteger, BigInteger) Method

정의

BigInteger 값에 대해 정수 나누기를 수행합니다.Performs integer division on two BigInteger values and returns the remainder.

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

매개 변수

dividend
BigInteger BigInteger BigInteger BigInteger

나눌 대상 값입니다.The value to be divided.

divisor
BigInteger BigInteger BigInteger BigInteger

나눌 값입니다.The value to divide by.

반환

dividenddivisor로 나눈 나머지입니다.The remainder after dividing dividend by divisor.

예외

예제

다음 예제를 비교 합니다 DivRem 반환한 나머지 메서드는 Remainder 에 두 메서드에 동일한 나머지를 계산 하는 설정 하는 방법입니다.The following example compares the remainder from the DivRem method with the remainder returned by the Remainder method to establish that the two methods calculate identical remainders.

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(7.8463771692333509522426190271E+56, 2147483647) = 1
//    BigInteger.DivRem(7.8463771692333509522426190271E+56, 2147483647) = 1
//    The remainders are equal.
//    
//    BigInteger.Remainder(-7.8463771692333509522426190271E+56, -2147483647) = -1
//    BigInteger.DivRem(-7.8463771692333509522426190271E+56, -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(7.8463771692333509522426190271E+56, 2147483647) = 1
'    BigInteger.DivRem(7.8463771692333509522426190271E+56, 2147483647) = 1
'    The remainders are equal.
'    
'    BigInteger.Remainder(-7.8463771692333509522426190271E+56, -2147483647) = -1
'    BigInteger.DivRem(-7.8463771692333509522426190271E+56, -2147483647) = -1
'    The remainders are equal.

설명

나머지의 부호는의 부호는 dividend 매개 변수입니다.The sign of the remainder is the sign of the dividend parameter.

Remainder 메서드는 사용자 지정 연산자를 지원 하지 않는 언어에 대 한 구현 됩니다.The Remainder method is implemented for languages that do not support custom operators. 해당 동작 나누기 모듈러스 연산자를 사용 하는 것과 동일 합니다.Its behavior is identical to division using the modulus operator.

경우 필요한 메서드에서 자동으로 수행 하는 다른 정수 계열 형식으로의 암시적 변환 BigInteger 나머지 작업을 수행 하기 전에 개체입니다.If necessary, the method automatically performs implicit conversion of other integral types to BigInteger objects before it performs the modulus operation.

적용 대상

추가 정보