BigInteger.Modulus(BigInteger, BigInteger) 运算符

定义

返回两个指定 BigInteger 值相除所得的余数。Returns the remainder that results from division with two specified BigInteger values.

public:
 static System::Numerics::BigInteger operator %(System::Numerics::BigInteger dividend, System::Numerics::BigInteger divisor);
public static System.Numerics.BigInteger operator % (System.Numerics.BigInteger dividend, System.Numerics.BigInteger divisor);
static member ( % ) : System.Numerics.BigInteger * System.Numerics.BigInteger -> System.Numerics.BigInteger
Public Shared Operator Mod (dividend As BigInteger, divisor As BigInteger) As BigInteger

参数

dividend
BigInteger

要作为被除数的值。The value to be divided.

divisor
BigInteger

要作为除数的值。The value to divide by.

返回

BigInteger

相除所得的余数。The remainder that results from the division.

例外

divisor 是 0(零)。divisor is 0 (zero).

注解

Modulus 方法定义 BigInteger 值的取模运算符的操作。The Modulus method defines the operation of the modulus operator for BigInteger values. 它可以实现如下所示的代码:It enables code such as the following:

BigInteger num1 = 100045632194;
BigInteger num2 = 90329434;
BigInteger remainder = num1 % num2;
Console.WriteLine(remainder);           // Displays 50948756
Dim num1 As BigInteger = 100045632194
Dim num2 As BigInteger = 90329434
Dim remainder As BigInteger = num1 Mod num2
Console.WriteLine(remainder)                 ' Displays  50948756 

不支持自定义运算符的语言可以改为调用 BigInteger.Remainder 方法。Languages that do not support custom operators can call the BigInteger.Remainder method instead.

取模操作返回的值的符号取决于 dividend的符号:如果 dividend 为正,则取模操作返回一个正的结果;如果为负,则取模操作返回一个负值。The sign of the value returned by the modulus operation depends on the sign of dividend: If dividend is positive, the modulus operation returns a positive result; if it is negative, the modulus operation returns a negative result. 具有 BigInteger 值的取模运算的行为与其他整型的取模运算相同。The behavior of the modulus operation with BigInteger values is identical to the modulus operation with other integral types.

此运算符的等效方法是 BigInteger.Remainder(BigInteger, BigInteger)The equivalent method for this operator is BigInteger.Remainder(BigInteger, BigInteger).

适用于

另请参阅