Modulo division of corresponding elements in two dynamic arrays (zero divide not 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, MODS
parses its value as 0 (zero).
Attempting to divide by zero generates a <DIVIDE> error, ending execution of the function and invoking an error trap handler, if available. This is the same 0 divisor behavior as the DIVS
function. In contrast, when the corresponding MODSZ
functions encounter a 0 divisor, they return 0 for that element.
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 MODS
function to return the modulo value for each division operation on the elements of two dynamic arrays:
PRINT MODS(a,b); ! returns 1ý0ý0ý-7