Returns the value of n mod m.
Namespace:
Meta.Numerics
Assembly:
Meta.Numerics (in Meta.Numerics.dll) Version: 4.1.4
Syntax public static long Mod(
long n,
long m
)
Public Shared Function Mod (
n As Long,
m As Long
) As Long
public:
static long long Mod(
long long n,
long long m
)
static member Mod :
n : int64 *
m : int64 -> int64
Parameters
- n
- Type: SystemInt64
The argument. - m
- Type: SystemInt64
The modulus.
Return Value
Type:
Int64The value of n mod m.
Remarks The modulus operator in .NET languages (n % m in C#, n Mod m in VB) returns
a negative remainder for negative n.
This is not consistent with the mathematical conventions of modular arithmetic,
which require that 0 ≤ n mod m < m. For example, in C# -7 % 4 returns -3
(which is simply the negative of 7 % 4), while mathematically -7 mod 4 = 1, as can
seen by extending the repeating 0, 1, 2, 3 pattern to negative integers. In cases
where it is important to obtain results consistent mathematical conventions,
you should call this method, which fixes the .NET result.
See Also