Description
The UnsignedMod
method is a static extension method in the SandboxSystemExtensions
class. It calculates the unsigned modulus of two integers, a
and b
. This method is useful when you need to ensure that the result of a modulus operation is always non-negative, even if the dividend is negative.
Usage
To use the UnsignedMod
method, pass two integer parameters, a
and b
, where a
is the dividend and b
is the divisor. The method will return the remainder of the division of a
by b
, ensuring that the result is non-negative.
Note: The divisor b
should not be zero, as this will result in a division by zero error.
Example
int result = SandboxSystemExtensions.UnsignedMod(-5, 3);
// result will be 1, because -5 mod 3 is 1 in unsigned modulus