- Function Mod(x, y)¶
Mod¶
Mod(
x, ! (input) numerical expression
y ! (input) numerical expression
)
Arguments¶
- x
A scalar numerical expression.
- y
A scalar numerical expression unequal to 0.
Return Value¶
The function
Mod
returns the remainder of \(x\) after division by \(|y|\). For \(y > 0\), the result is an integer in the range \(0,\dots,y-1\) if both \(x\) and \(y\) are integers, or in the interval \([0,y)\) otherwise. For \(y < 0\), the result is an integer in the range \(y-1,\dots,0\) if both \(x\) and \(y\) are integers, or in the interval \((y,0]\) otherwise.
Note
A run-time error results if y equals 0.
The function
Mod
can be used in constraints of mathematical programs. However, nonlinear solver may experience convergence problems if \(x\) assumes values around multiples of \(y\).
See also
Arithmetic functions are discussed in full detail in Arithmetic Functions of the Language Reference.