Modulo division of corresponding elements in two dynamic arrays (zero divide allowed).
function divides the value of each element in dynarray1
by the corresponding element in dynarray2
. It then returns a dynamic array containing the modulo (remainder) for each element that results from these divisions. If an element is missing or has a null string or a non-numeric value, MODSZ
parses its value as 0 (zero).
encounters a 0 divisor, it returns 0 for that element. This is the same 0 divisor behavior as the DIVSZ
function. The corresponding MODS
function does not allow division by zero; attempting to divide by zero generates a <DIVIDE> error, ending execution of the function and invoking an error trap handler, if available.
If the two dynamic arrays have different numbers of elements, the returned dynamic array has the number of elements of the longer dynamic array. By default, the shorter dynamic array is padded with 0 value elements for the purpose of the arithmetic operation. You can also use the REUSE
function to define behavior when specifying two dynamic arrays with different numbers of elements.
You can use the MOD
function or the REM
function to perform modulo division on single values.
You can use the NUMS
function to determine if the elements in a dynamic array are numeric. You can use the ADDS
(division), and PWRS
(exponentiation) functions to perform other arithmetic operations on the corresponding elements of two dynamic arrays.
The following example uses the MODSZ
function to return the modulo value for each division operation on the elements of two dynamic arrays:
PRINT MODSZ(a,b); ! returns 1ý0ý0ý-7
© 1997-2019 InterSystems Corporation, Cambridge, MA