Caché MultiValue Basic Reference
DIVSZ


Divides the corresponding elements in two dynamic arrays (zero divide allowed).
Synopsis
DIVSZ(dynarray1,dynarray2)
Arguments
Description
The
DIVSZ and
DIVS functions are identical, with one difference:

When
DIVSZ encounters a 0 divisor, it returns 0 for that element.

When
DIVS encounters a 0 divisor, it generates a <DIVIDE> error, ending execution of the function.
The
DIVSZ function divides the value of each element in
dynarray1 by the corresponding element in
dynarray2. It then returns a dynamic array containing the results of these divisions. If an element value is an empty string or a nonnumeric value,
DIVSZ parses its value as 0 (zero).
DIVSZ and
DIVS can return fractional numbers as the result (quotient) of a division operation. The
DIV function can only return the integer portion of the result (quotient) of a division operation; the fractional portion is truncated.
If the two dynamic arrays have different numbers of elements, by default the shorter dynamic array is padded so that the returned dynamic array has the number of elements of the longer dynamic array. If the shorter dynamic array is the dividend (
dynarray1), it is padded with the required number of elements with the value of 0. If the shorter dynamic array is the divisor (
dynarray2), it is padded with the required number of elements with the value of 1. You can also use the
REUSE function to define behavior when specifying two dynamic arrays with different numbers of elements.
You can use the
NUMS function to determine if the elements in a dynamic array are numeric. You can use the
ADDS (addition),
SUBS (subtraction),
MULS (multiplication),
MODS and
MODSZ (modulo division), and
PWRS (exponentiation) functions to perform other arithmetic operations on the corresponding elements of two dynamic arrays.
Examples
The following example uses the
DIVSZ function to divide the elements of two dynamic arrays:
a=11:@VM:22:@VM:0:@VM:7
b=10:@VM:.5:@VM:10:@VM:42
PRINT DIVSZ(a,b)
! returns 1.1ý44ý0ý.1666666666667
The following example uses
DIVSZ to divide the elements of two dynamic arrays, when the divisor array contains zero values:
a=11:@VM:22:@VM:0:@VM:7:@VM:6
b=10:@VM:0:@VM:10:@VM:"":@VM:2
PRINT DIVSZ(a,b)
! returns 1.1ý0ý0ý0ý3
See Also